Log the magic bytes if an image fails to load

Often, on the raylib discord server, people try to load things like jpg
renamed to png, which obviously doesn't work. Adding this log will allow
easier identification of when this is happening.
This commit is contained in:
Peter0x44 2023-06-15 20:18:32 +01:00
parent 7392c4b0c5
commit 2c95d7f662
No known key found for this signature in database
GPG Key ID: 61D477F61F3364B3

View File

@ -451,7 +451,11 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
else TRACELOG(LOG_WARNING, "IMAGE: Data format not supported"); else TRACELOG(LOG_WARNING, "IMAGE: Data format not supported");
if (image.data != NULL) TRACELOG(LOG_INFO, "IMAGE: Data loaded successfully (%ix%i | %s | %i mipmaps)", image.width, image.height, rlGetPixelFormatName(image.format), image.mipmaps); if (image.data != NULL) TRACELOG(LOG_INFO, "IMAGE: Data loaded successfully (%ix%i | %s | %i mipmaps)", image.width, image.height, rlGetPixelFormatName(image.format), image.mipmaps);
else TRACELOG(LOG_WARNING, "IMAGE: Failed to load image data"); else
{
TRACELOG(LOG_WARNING, "IMAGE: Failed to load image data");
TRACELOG(LOG_WARNING, "IMAGE: Magic bytes are: %x %x %x %x", fileData[0], fileData[1], fileData[2], fileData[3]);
}
return image; return image;
} }