Replace UINT32 assignment with per-channel UINT8 assignment

This commit is contained in:
homm 2014-11-09 02:27:43 +03:00
parent abc5e11371
commit 7a64f7be80

View File

@ -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;