From 0db417fcb5e3ed6e1b92b382445fb1d807da35ed Mon Sep 17 00:00:00 2001 From: grumbel Date: Sun, 6 Dec 2009 21:40:01 +0000 Subject: [PATCH] Copy the palette of indexed images, fixes issue with the boats worldmap path which didn't show up git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6187 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/video/texture_manager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/video/texture_manager.cpp b/src/video/texture_manager.cpp index 6caf48595..3831132bb 100644 --- a/src/video/texture_manager.cpp +++ b/src/video/texture_manager.cpp @@ -121,7 +121,10 @@ TextureManager::create_image_texture_raw(const std::string& filename, const Rect } else { - SDLSurfacePtr subimage(SDL_CreateRGBSurfaceFrom(static_cast(image->pixels) + rect.top * image->pitch + rect.left * image->format->BytesPerPixel, + SDLSurfacePtr subimage(SDL_CreateRGBSurfaceFrom(static_cast(image->pixels) + + rect.top * image->pitch + + rect.left * image->format->BytesPerPixel, + rect.get_width(), rect.get_height(), image->format->BitsPerPixel, image->pitch, @@ -135,6 +138,11 @@ TextureManager::create_image_texture_raw(const std::string& filename, const Rect } else { + if (image->format->palette) + { // copy the image palette to subimage if present + SDL_SetColors(subimage.get(), image->format->palette->colors, 0, image->format->palette->ncolors); + } + Texture* result = VideoSystem::new_texture(subimage.get()); result->set_filename(filename); return result; -- 2.11.0