From 7a1e73e7f95b34c9315732531e20968b203cc8d3 Mon Sep 17 00:00:00 2001 From: Tobias Markus Date: Sat, 7 Mar 2015 18:44:13 +0100 Subject: [PATCH] Fix for images with invalid pixel formats --- src/video/texture_manager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/video/texture_manager.cpp b/src/video/texture_manager.cpp index 6dba671a4..ae272b323 100644 --- a/src/video/texture_manager.cpp +++ b/src/video/texture_manager.cpp @@ -146,7 +146,17 @@ TextureManager::create_image_texture_raw(const std::string& filename, const Rect throw std::runtime_error(msg.str()); } - m_surfaces[filename] = image; + SDL_PixelFormat* format = image->format; + if(format->Rmask == 0 && format->Gmask == 0 && format->Bmask == 0 && format->Amask == 0) { + log_warning << "Wrong surface format for image " << filename << ". Compensating." << std::endl; + + SDL_Surface* converted_surf = SDL_ConvertSurfaceFormat(image, SDL_PIXELFORMAT_RGBA8888, 0); + m_surfaces[filename] = converted_surf; + } + else + { + m_surfaces[filename] = image; + } } SDLSurfacePtr subimage(SDL_CreateRGBSurfaceFrom(static_cast(image->pixels) + -- 2.11.0