From 6967db837bf42b6d647e0e6a29a403446e6f703a Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 20 Nov 2002 01:54:15 +0000 Subject: [PATCH] fix black dots in images (finally) --- stepmania/src/SDL_utils.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index 7c17507266..b2f8e28379 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -161,8 +161,22 @@ void ConvertSDLSurface(SDL_Surface *&image, /* I'd really like to do away with this, but a lot of song images use it. * I suppose this should be yet another hint, but they're getting cumbersome ... */ - if(!(image->flags & SDL_SRCCOLORKEY)) - SDL_SetColorKey( image, SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 0xFF, 0, 0xFF)); + if(!(image->flags & SDL_SRCCOLORKEY)) { + /* Annoying: SDL will do a nearest-match on paletted images if + * they don't have the color we ask for, so images without HOT PINK + * will get some other random color transparent; so we have to make + * sure the value returned for paletted images is exactly #FF00FF. */ + int color = SDL_MapRGB(image->format, 0xFF, 0, 0xFF); + if( image->format->BitsPerPixel == 8 ) { + if(image->format->palette->colors[color].r != 0xFF || + image->format->palette->colors[color].g != 0x00 || + image->format->palette->colors[color].b != 0xFF ) + color = -1; + } + + if( color != -1 ) + SDL_SetColorKey( image, SDL_SRCCOLORKEY, color); + } /* We don't want to actually blend the alpha channel over the destination converted * surface; we want to simply blit it, so make sure SDL_SRCALPHA is not on. */