summaryrefslogtreecommitdiffhomepage
path: root/src/rtextures.c
diff options
context:
space:
mode:
authorRay <[email protected]>2022-07-10 21:12:34 +0200
committerRay <[email protected]>2022-07-10 21:12:34 +0200
commit29a0f6077871987e28f98b34f4d64af42d997014 (patch)
tree6fcc345a59d741c00b360d9f39dc60cfdaef1ed8 /src/rtextures.c
parent05dc300296e32e1f005d10ded9473d0b0387ae95 (diff)
downloadraylib-29a0f6077871987e28f98b34f4d64af42d997014.tar.gz
raylib-29a0f6077871987e28f98b34f4d64af42d997014.zip
REVIEWED: `ImageResize()` #2572
Diffstat (limited to 'src/rtextures.c')
-rw-r--r--src/rtextures.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rtextures.c b/src/rtextures.c
index 3328553c..7cc350c5 100644
--- a/src/rtextures.c
+++ b/src/rtextures.c
@@ -1414,10 +1414,12 @@ void ImageResize(Image *image, int newWidth, int newHeight)
// Security check to avoid program crash
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
- bool fastPath = true;
- if ((image->format != PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) && (image->format != PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) && (image->format != PIXELFORMAT_UNCOMPRESSED_R8G8B8) && (image->format != PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)) fastPath = true;
-
- if (fastPath)
+ // Check if we can use a fast path on image scaling
+ // It can be for 8 bit per channel images with 1 to 4 channels per pixel
+ if ((image->format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) ||
+ (image->format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) ||
+ (image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) ||
+ (image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8))
{
int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
unsigned char *output = (unsigned char *)RL_MALLOC(newWidth*newHeight*bytesPerPixel);