From 40bc6afdbd06d213a07a5e321f4f285d613a1fe5 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Mon, 8 Jun 2020 18:23:59 +0200 Subject: [PATCH] REVIEWED: ImageAlphaClear(), minor optimization --- src/textures.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/textures.c b/src/textures.c index df7b35be3..1a8af6149 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1107,8 +1107,9 @@ void ImageAlphaClear(Image *image, Color color, float threshold) if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return; Color *pixels = GetImageData(*image); + unsigned char thresholdValue = (unsigned char)(threshold*255.0f); - for (int i = 0; i < image->width*image->height; i++) if (pixels[i].a <= (unsigned char)(threshold*255.0f)) pixels[i] = color; + for (int i = 0; i < image->width*image->height; i++) if (pixels[i].a <= thresholdValue) pixels[i] = color; RL_FREE(image->data); int format = image->format;