GetImageData() returns NULL if image size is 0

This commit is contained in:
Ray
2020-01-15 11:22:00 +01:00
parent 22b7713287
commit 4525c897e2

View File

@@ -457,9 +457,9 @@ void UnloadRenderTexture(RenderTexture2D target)
// Get pixel data from image in the form of Color struct array // Get pixel data from image in the form of Color struct array
Color *GetImageData(Image image) Color *GetImageData(Image image)
{ {
Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color)); if ((image.width == 0) || (image.height == 0)) return NULL;
if (pixels == NULL) return pixels; Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color));
if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats"); if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
else else