mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
speedup RGBa -> RGBA conversion in most cases
This commit is contained in:
parent
c4b92d09b7
commit
d1272b9b8a
|
@ -463,14 +463,14 @@ rgba2rgbA(UINT8* out, const UINT8* in, int xsize)
|
|||
unsigned int alpha;
|
||||
for (x = 0; x < xsize; x++, in+=4) {
|
||||
alpha = in[3];
|
||||
if (alpha) {
|
||||
*out++ = CLIP((255 * in[0]) / alpha);
|
||||
*out++ = CLIP((255 * in[1]) / alpha);
|
||||
*out++ = CLIP((255 * in[2]) / alpha);
|
||||
} else {
|
||||
if (alpha == 255 || alpha == 0) {
|
||||
*out++ = in[0];
|
||||
*out++ = in[1];
|
||||
*out++ = in[2];
|
||||
} else {
|
||||
*out++ = CLIP((255 * in[0]) / alpha);
|
||||
*out++ = CLIP((255 * in[1]) / alpha);
|
||||
*out++ = CLIP((255 * in[2]) / alpha);
|
||||
}
|
||||
*out++ = in[3];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user