mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Replace UINT32 assignment with per-channel UINT8 assignment
This commit is contained in:
parent
abc5e11371
commit
7a64f7be80
|
@ -212,36 +212,39 @@ ImagingStretchHorizontal(Imaging imIn, int xsize, int filter)
|
||||||
switch(imIn->type) {
|
switch(imIn->type) {
|
||||||
case IMAGING_TYPE_UINT8:
|
case IMAGING_TYPE_UINT8:
|
||||||
/* n-bit grayscale */
|
/* n-bit grayscale */
|
||||||
for (xx = 0; xx < xsize; xx++) {
|
if (imIn->bands == 2) {
|
||||||
xmin = xbounds[xx * 2 + 0];
|
for (xx = 0; xx < xsize; xx++) {
|
||||||
xmax = xbounds[xx * 2 + 1];
|
xmin = xbounds[xx * 2 + 0];
|
||||||
k = &kk[xx * kmax];
|
xmax = xbounds[xx * 2 + 1];
|
||||||
if (imIn->bands == 2) {
|
k = &kk[xx * kmax];
|
||||||
ss0 = ss1 = 0.5;
|
ss0 = ss1 = 0.5;
|
||||||
for (x = xmin; x < xmax; x++) {
|
for (x = xmin; x < xmax; x++) {
|
||||||
ss0 += i2f((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
ss0 += i2f((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
||||||
ss1 += i2f((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin];
|
ss1 += i2f((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin];
|
||||||
}
|
}
|
||||||
#ifdef WORDS_BIGENDIAN
|
imOut->image[yy][xx*4 + 0] = clip8(ss0);
|
||||||
imOut->image32[yy][xx] = clip8(ss1) | clip8(ss0) << 24;
|
imOut->image[yy][xx*4 + 3] = clip8(ss1);
|
||||||
#else
|
}
|
||||||
imOut->image32[yy][xx] = clip8(ss0) | clip8(ss1) << 24;
|
} else if (imIn->bands == 3) {
|
||||||
#endif
|
for (xx = 0; xx < xsize; xx++) {
|
||||||
} else if (imIn->bands == 3) {
|
xmin = xbounds[xx * 2 + 0];
|
||||||
|
xmax = xbounds[xx * 2 + 1];
|
||||||
|
k = &kk[xx * kmax];
|
||||||
ss0 = ss1 = ss2 = 0.5;
|
ss0 = ss1 = ss2 = 0.5;
|
||||||
for (x = xmin; x < xmax; x++) {
|
for (x = xmin; x < xmax; x++) {
|
||||||
ss0 += i2f((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
ss0 += i2f((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
||||||
ss1 += i2f((UINT8) imIn->image[yy][x*4 + 1]) * 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];
|
ss2 += i2f((UINT8) imIn->image[yy][x*4 + 2]) * k[x - xmin];
|
||||||
}
|
}
|
||||||
#ifdef WORDS_BIGENDIAN
|
imOut->image[yy][xx*4 + 0] = clip8(ss0);
|
||||||
imOut->image32[yy][xx] =
|
imOut->image[yy][xx*4 + 1] = clip8(ss1);
|
||||||
clip8(ss2) << 8 | clip8(ss1) << 16 | clip8(ss0) << 24;
|
imOut->image[yy][xx*4 + 2] = clip8(ss2);
|
||||||
#else
|
}
|
||||||
imOut->image32[yy][xx] =
|
} else {
|
||||||
clip8(ss0) | clip8(ss1) << 8 | clip8(ss2) << 16;
|
for (xx = 0; xx < xsize; xx++) {
|
||||||
#endif
|
xmin = xbounds[xx * 2 + 0];
|
||||||
} else {
|
xmax = xbounds[xx * 2 + 1];
|
||||||
|
k = &kk[xx * kmax];
|
||||||
ss0 = ss1 = ss2 = ss3 = 0.5;
|
ss0 = ss1 = ss2 = ss3 = 0.5;
|
||||||
for (x = xmin; x < xmax; x++) {
|
for (x = xmin; x < xmax; x++) {
|
||||||
ss0 += i2f((UINT8) imIn->image[yy][x*4 + 0]) * k[x - xmin];
|
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];
|
ss2 += i2f((UINT8) imIn->image[yy][x*4 + 2]) * k[x - xmin];
|
||||||
ss3 += i2f((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin];
|
ss3 += i2f((UINT8) imIn->image[yy][x*4 + 3]) * k[x - xmin];
|
||||||
}
|
}
|
||||||
#ifdef WORDS_BIGENDIAN
|
imOut->image[yy][xx*4 + 0] = clip8(ss0);
|
||||||
imOut->image32[yy][xx] =
|
imOut->image[yy][xx*4 + 1] = clip8(ss1);
|
||||||
clip8(ss3) | clip8(ss2) << 8 |
|
imOut->image[yy][xx*4 + 2] = clip8(ss2);
|
||||||
clip8(ss1) << 16 | clip8(ss0) << 24;
|
imOut->image[yy][xx*4 + 3] = clip8(ss3);
|
||||||
#else
|
|
||||||
imOut->image32[yy][xx] =
|
|
||||||
clip8(ss0) | clip8(ss1) << 8 |
|
|
||||||
clip8(ss2) << 16 | clip8(ss3) << 24;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user