speedup RGBa -> RGBA conversion in most cases

This commit is contained in:
homm 2016-05-10 20:52:46 +02:00
parent c4b92d09b7
commit d1272b9b8a

View File

@ -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];
}