fix overflow in cast for ImageBlurGaussian

This commit is contained in:
garrisonhh
2025-07-10 12:48:29 -04:00
parent 55a5674714
commit 8dbacafbe6

View File

@ -2217,9 +2217,9 @@ void ImageBlurGaussian(Image *image, int blurSize)
else if (pixelsCopy1[i].w <= 255.0f) else if (pixelsCopy1[i].w <= 255.0f)
{ {
float alpha = (float)pixelsCopy1[i].w/255.0f; float alpha = (float)pixelsCopy1[i].w/255.0f;
pixels[i].r = (unsigned char)((float)pixelsCopy1[i].x/alpha); pixels[i].r = (unsigned char)fminf((float)pixelsCopy1[i].x/alpha, 255.0);
pixels[i].g = (unsigned char)((float)pixelsCopy1[i].y/alpha); pixels[i].g = (unsigned char)fminf((float)pixelsCopy1[i].y/alpha, 255.0);
pixels[i].b = (unsigned char)((float)pixelsCopy1[i].z/alpha); pixels[i].b = (unsigned char)fminf((float)pixelsCopy1[i].z/alpha, 255.0);
pixels[i].a = (unsigned char) pixelsCopy1[i].w; pixels[i].a = (unsigned char) pixelsCopy1[i].w;
} }
} }