From 2c95d7f66248b1d4b0e31503d2c24d889e5ab4c5 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Thu, 15 Jun 2023 20:18:32 +0100 Subject: [PATCH] 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. --- src/rtextures.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rtextures.c b/src/rtextures.c index 7d76616c1..8f37bd6d0 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -451,7 +451,11 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i 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); - 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; }