diff --git a/libImaging/Convert.c b/libImaging/Convert.c index f5931394f..5aad3733c 100644 --- a/libImaging/Convert.c +++ b/libImaging/Convert.c @@ -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]; }