Archived

This topic is now archived and is closed to further replies.

SDL & SDL_SetColorKey()

This topic is 5796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i''m getting a really wierd problem. i can get SDL_SetColorKey() to work perfectly on surface "surface". But, if i make an identical (int size && depth) surface, blit from "surface" to "tempSurface", then blit from "tempSurface" to "surface", the ColorKey doesnt work anymore... So, i tried resetting the color key, and nothing. Still the ugly pink (supposed to be clear) background on my surface.... Any suggestions?? <the getting madder fast> MadProgrammer

Share this post


Link to post
Share on other sites
    
surface = SDL_LoadBMP(temp);
SDL_SetColorKey(surface, SDL_SRCCOLORKEY, SDL_MapRGB(surface->format, br, bg, bb));

SDL_Surface *surf = SDL_CreateRGBSurface(SDL_HWSURFACE, surface->w, surface->h, surface->format->BytesPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
SDL_BlitSurface(surface, 0, surf, 0);
SDL_BlitSurface(surf, 0, surface, 0);
SDL_FreeSurface(surf);
SDL_SetColorKey(surface, SDL_SRCCOLORKEY, SDL_MapRGB(surface->format, br, bg, bb));


w/ or w/o that last color key, "surface" is NOT color keyed
if i just do the first 2 lines (loadBMP & SetColorKey), the surface IS color keyed

i'm stumped 100%

Edited by - MadProgrammer on January 30, 2002 4:31:50 PM [/source]

Edited by - MadProgrammer on January 30, 2002 4:32:19 PM

Share this post


Link to post
Share on other sites
The color key is not applied until you blit or convert the surface. Perhaps the surface is being converted when you first blit from it, such that your color key is no longer valid. This could be because your image is being loaded in a different bit depth to your video resolution. I don''t see why this wouldn''t work following the last line, but the problem might be something like this. I suggest you post on the SDL mailing list (http://www.libsdl.org/mailman/listinfo/sdl) and see what they say. If you get a good answer, post it back up here so we can see what it was.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]

Share this post


Link to post
Share on other sites