From 7a64f7be80ac675b2eec079f8430de964afbc408 Mon Sep 17 00:00:00 2001 From: homm Date: Sun, 9 Nov 2014 02:27:43 +0300 Subject: [PATCH] Replace UINT32 assignment with per-channel UINT8 assignment --- libImaging/Antialias.c | 54 ++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/libImaging/Antialias.c b/libImaging/Antialias.c index fd2ec51be..4b997eaa9 100644 --- a/libImaging/Antialias.c +++ b/libImaging/Antialias.c @@ -212,36 +212,39 @@ ImagingStretchHorizontal(Imaging imIn, int xsize, int filter) switch(imIn->type) { case IMAGING_TYPE_UINT8: /* n-bit grayscale */ - for (xx = 0; xx < xsize; xx++) { - xmin = xbounds[xx * 2 + 0]; - xmax = xbounds[xx * 2 + 1]; - k = &kk[xx * kmax]; - if (imIn->bands == 2) { + if (imIn->bands == 2) { + for (xx = 0; xx < xsize; xx++) { + xmin = xbounds[xx * 2 + 0]; + xmax = xbounds[xx * 2 + 1]; + k = &kk[xx * kmax]; ss0 = ss1 = 0.5; for (x = xmin; x < xmax; x++) { ss0 += i2f((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin]; ss1 += i2f((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin]; } -#ifdef WORDS_BIGENDIAN - imOut->image32[yy][xx] = clip8(ss1) | clip8(ss0) << 24; -#else - imOut->image32[yy][xx] = clip8(ss0) | clip8(ss1) << 24; -#endif - } else if (imIn->bands == 3) { + imOut->image[yy][xx*4 + 0] = clip8(ss0); + imOut->image[yy][xx*4 + 3] = clip8(ss1); + } + } else if (imIn->bands == 3) { + for (xx = 0; xx < xsize; xx++) { + xmin = xbounds[xx * 2 + 0]; + xmax = xbounds[xx * 2 + 1]; + k = &kk[xx * kmax]; ss0 = ss1 = ss2 = 0.5; for (x = xmin; x < xmax; x++) { ss0 += i2f((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin]; ss1 += i2f((UINT8) imIn->image[yy][x*4 + 1]) * k[x - xmin]; ss2 += i2f((UINT8) imIn->image[yy][x*4 + 2]) * k[x - xmin]; } -#ifdef WORDS_BIGENDIAN - imOut->image32[yy][xx] = - clip8(ss2) << 8 | clip8(ss1) << 16 | clip8(ss0) << 24; -#else - imOut->image32[yy][xx] = - clip8(ss0) | clip8(ss1) << 8 | clip8(ss2) << 16; -#endif - } else { + imOut->image[yy][xx*4 + 0] = clip8(ss0); + imOut->image[yy][xx*4 + 1] = clip8(ss1); + imOut->image[yy][xx*4 + 2] = clip8(ss2); + } + } else { + for (xx = 0; xx < xsize; xx++) { + xmin = xbounds[xx * 2 + 0]; + xmax = xbounds[xx * 2 + 1]; + k = &kk[xx * kmax]; ss0 = ss1 = ss2 = ss3 = 0.5; for (x = xmin; x < xmax; x++) { ss0 += i2f((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin]; @@ -249,15 +252,10 @@ ImagingStretchHorizontal(Imaging imIn, int xsize, int filter) ss2 += i2f((UINT8) imIn->image[yy][x*4 + 2]) * k[x - xmin]; ss3 += i2f((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin]; } -#ifdef WORDS_BIGENDIAN - imOut->image32[yy][xx] = - clip8(ss3) | clip8(ss2) << 8 | - clip8(ss1) << 16 | clip8(ss0) << 24; -#else - imOut->image32[yy][xx] = - clip8(ss0) | clip8(ss1) << 8 | - clip8(ss2) << 16 | clip8(ss3) << 24; -#endif + imOut->image[yy][xx*4 + 0] = clip8(ss0); + imOut->image[yy][xx*4 + 1] = clip8(ss1); + imOut->image[yy][xx*4 + 2] = clip8(ss2); + imOut->image[yy][xx*4 + 3] = clip8(ss3); } } break;