diff --git a/desktop_version/src/GraphicsResources.cpp b/desktop_version/src/GraphicsResources.cpp index 379cef3c..3822da1e 100644 --- a/desktop_version/src/GraphicsResources.cpp +++ b/desktop_version/src/GraphicsResources.cpp @@ -20,6 +20,7 @@ extern "C" const unsigned char* in, size_t insize ); + extern const char* lodepng_error_text(unsigned code); } static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool noAlpha = false) @@ -31,6 +32,7 @@ static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool no unsigned char *data; unsigned int width, height; + unsigned int error; unsigned char *fileIn; size_t length; @@ -42,14 +44,20 @@ static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool no } if (noAlpha) { - lodepng_decode24(&data, &width, &height, fileIn, length); + error = lodepng_decode24(&data, &width, &height, fileIn, length); } else { - lodepng_decode32(&data, &width, &height, fileIn, length); + error = lodepng_decode32(&data, &width, &height, fileIn, length); } FILESYSTEM_freeMemory(&fileIn); + if (error != 0) + { + vlog_error("Could not load %s: %s", filename, lodepng_error_text(error)); + return NULL; + } + loadedImage = SDL_CreateRGBSurfaceWithFormatFrom( data, width,