diff --git a/src/raylib.h b/src/raylib.h index f7eebd08b..d85a97cfb 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1402,7 +1402,7 @@ RLAPI void ImageRotateCCW(Image *image); RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint RLAPI void ImageColorInvert(Image *image); // Modify image color: invert RLAPI void ImageColorGrayscale(Image *image); // Modify image color: grayscale -RLAPI void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) +RLAPI void ImageColorContrast(Image *image, int contrast); // Modify image color: contrast (-100 to 100) RLAPI void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) RLAPI void ImageColorReplace(Image *image, Color color, Color replace); // Modify image color: replace color RLAPI Color *LoadImageColors(Image image); // Load color data from image as a Color array (RGBA - 32bit) diff --git a/src/rtextures.c b/src/rtextures.c index 80206ecf7..ba50d9d02 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -2795,7 +2795,7 @@ void ImageColorGrayscale(Image *image) // Modify image color: contrast // NOTE: Contrast values between -100 and 100 -void ImageColorContrast(Image *image, float contrast) +void ImageColorContrast(Image *image, int contrast) { // Security check to avoid program crash if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return; @@ -2803,8 +2803,8 @@ void ImageColorContrast(Image *image, float contrast) if (contrast < -100) contrast = -100; if (contrast > 100) contrast = 100; - contrast = (100.0f + contrast)/100.0f; - contrast *= contrast; + float factor = (float)(100.0f + contrast)/100.0f; + factor *= factor; Color *pixels = LoadImageColors(*image); @@ -2812,7 +2812,7 @@ void ImageColorContrast(Image *image, float contrast) { float pR = (float)pixels[i].r/255.0f; pR -= 0.5f; - pR *= contrast; + pR *= factor; pR += 0.5f; pR *= 255; if (pR < 0) pR = 0; @@ -2820,7 +2820,7 @@ void ImageColorContrast(Image *image, float contrast) float pG = (float)pixels[i].g/255.0f; pG -= 0.5f; - pG *= contrast; + pG *= factor; pG += 0.5f; pG *= 255; if (pG < 0) pG = 0; @@ -2828,7 +2828,7 @@ void ImageColorContrast(Image *image, float contrast) float pB = (float)pixels[i].b/255.0f; pB -= 0.5f; - pB *= contrast; + pB *= factor; pB += 0.5f; pB *= 255; if (pB < 0) pB = 0;