REVIEWED: ImageResize()
#2572
This commit is contained in:
parent
05dc300296
commit
29a0f60778
1 changed files with 6 additions and 4 deletions
|
@ -1414,10 +1414,12 @@ void ImageResize(Image *image, int newWidth, int newHeight)
|
||||||
// Security check to avoid program crash
|
// Security check to avoid program crash
|
||||||
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
|
||||||
|
|
||||||
bool fastPath = true;
|
// Check if we can use a fast path on image scaling
|
||||||
if ((image->format != PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) && (image->format != PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) && (image->format != PIXELFORMAT_UNCOMPRESSED_R8G8B8) && (image->format != PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)) fastPath = true;
|
// It can be for 8 bit per channel images with 1 to 4 channels per pixel
|
||||||
|
if ((image->format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) ||
|
||||||
if (fastPath)
|
(image->format == PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) ||
|
||||||
|
(image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) ||
|
||||||
|
(image->format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8))
|
||||||
{
|
{
|
||||||
int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
|
int bytesPerPixel = GetPixelDataSize(1, 1, image->format);
|
||||||
unsigned char *output = (unsigned char *)RL_MALLOC(newWidth*newHeight*bytesPerPixel);
|
unsigned char *output = (unsigned char *)RL_MALLOC(newWidth*newHeight*bytesPerPixel);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue