avoid case w/255.5+0.5 (kudos @cmb69)

master
Pierre Joye 2021-08-25 00:09:05 +07:00
parent 8890f527b2
commit 49ecef1bf4
1 changed files with 4 additions and 4 deletions

View File

@ -3540,10 +3540,10 @@ BGD_DECLARE(void) gdImageCopyResampled (gdImagePtr dst,
blue /= alpha_sum;
}
/* Round up closest next channel value and clamp to max channel value */
red = red > 255.5 ? 255 : red+0.5;
blue = blue > 255.5 ? 255 : blue+0.5;
green = green > 255.5 ? 255 : green+0.5;
alpha = alpha > gdAlphaMax+0.5 ? 255 : alpha+0.5;
red = red >= 255.5 ? 255 : red+0.5;
blue = blue >= 255.5 ? 255 : blue+0.5;
green = green >= 255.5 ? 255 : green+0.5;
alpha = alpha >= gdAlphaMax+0.5 ? 255 : alpha+0.5;
gdImageSetPixel(dst, x, y, gdTrueColorAlpha ((int)red, (int)green, (int)blue, (int)alpha));
}
}