mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
cache hasAlpha for ImagingUnsharpMask
This commit is contained in:
parent
e56aed1a95
commit
bef7e1dce8
|
@ -293,6 +293,7 @@ ImagingUnsharpMask(Imaging im, Imaging imOut, float radius, int percent,
|
|||
int channel = 0;
|
||||
int channels = 0;
|
||||
int padding = 0;
|
||||
int hasAlpha = 0;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
@ -337,6 +338,10 @@ ImagingUnsharpMask(Imaging im, Imaging imOut, float radius, int percent,
|
|||
|
||||
ImagingSectionEnter(&cookie);
|
||||
|
||||
if (strcmp(im->mode, "RGBX") == 0 || strcmp(im->mode, "RGBA") == 0) {
|
||||
hasAlpha = 1;
|
||||
}
|
||||
|
||||
for (y = 0; y < im->ysize; y++) {
|
||||
if (channels == 1) {
|
||||
lineIn8 = im->image8[y];
|
||||
|
@ -385,8 +390,7 @@ ImagingUnsharpMask(Imaging im, Imaging imOut, float radius, int percent,
|
|||
(channel * 8);
|
||||
}
|
||||
}
|
||||
if (strcmp(im->mode, "RGBX") == 0
|
||||
|| strcmp(im->mode, "RGBA") == 0) {
|
||||
if (hasAlpha) {
|
||||
/* preserve the alpha channel
|
||||
this may not work for little-endian systems, fix it! */
|
||||
newPixel =
|
||||
|
|
Loading…
Reference in New Issue
Block a user