Merge pull request #6650 from radarhere/performance

Moved mode check outside of loops
This commit is contained in:
Hugo van Kemenade 2022-10-10 06:16:08 +02:00 committed by GitHub
commit 6724b092cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -432,18 +432,18 @@ fill_mask_L(
}
} else {
int alpha_channel = strcmp(imOut->mode, "RGBa") == 0 ||
strcmp(imOut->mode, "RGBA") == 0 ||
strcmp(imOut->mode, "La") == 0 ||
strcmp(imOut->mode, "LA") == 0 ||
strcmp(imOut->mode, "PA") == 0;
for (y = 0; y < ysize; y++) {
UINT8 *out = (UINT8 *)imOut->image[y + dy] + dx * pixelsize;
UINT8 *mask = (UINT8 *)imMask->image[y + sy] + sx;
for (x = 0; x < xsize; x++) {
for (i = 0; i < pixelsize; i++) {
UINT8 channel_mask = *mask;
if ((strcmp(imOut->mode, "RGBa") == 0 ||
strcmp(imOut->mode, "RGBA") == 0 ||
strcmp(imOut->mode, "La") == 0 ||
strcmp(imOut->mode, "LA") == 0 ||
strcmp(imOut->mode, "PA") == 0) &&
i != 3 && channel_mask != 0) {
if (alpha_channel && i != 3 && channel_mask != 0) {
channel_mask =
255 - (255 - channel_mask) * (1 - (255 - out[3]) / 255);
}