From d1272b9b8ab5be127a300a08e439ebd61841619d Mon Sep 17 00:00:00 2001 From: homm Date: Tue, 10 May 2016 20:52:46 +0200 Subject: [PATCH] speedup RGBa -> RGBA conversion in most cases --- libImaging/Convert.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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]; }