• Advertisement
Sign in to follow this  

SDL Color Key Problems

This topic is 1449 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

Hello. Im having strange problem with ColorKey in SDL. When i use small images the colorkey does not complete and it leaves some stroke around the sprite. I dont know why. Strangely with bigger images it works fine. 

 

Also i have map file with different values that are mapped to different tiles in the bmp file. The bmp file has that blueish background. The program reads the map file and the bmp file and based on values in the map file it Blits different tiles on screen. The ground appears good but when it comes to those wooden rails it leaves some stroke.

 

ads.png

 

Here is some code :

Sprite class:

class Sprite
{
    private:
          SDL_Surface *image;
   public:
       /..../
        void LoadImage(const char *src);
        void AddTransparency(Uint32 ColorKey);
       /....../
};

Somewhere in the main code:

SDL_Surface *Screen; //main screen surface
/....../
Sprite Background;
Sprite Tiles;
Background.LoadImage("bg.bmp");
Tiles.LoadImage("tiles.bmp");
Uint32 ColorKey = SDL_MapRGB(Screen->format, 0x5E, 0x81, 0xA2);
Tiles.AddTransparency(ColorKey);

And in the AddTransparency function i do :

void Sprite::AddTransparency(Uint32 ColorKey){
       SDL_SetColorKey(image, SDL_SRCCOLORKEY, ColorKey);
}
Edited by aliasc

Share this post


Link to post
Share on other sites
Advertisement

Actually i solved the problem by using more light strong colors like light green, light orange cyan or magenta. These are strong colors with maximum white which gives more light to it and it seems that they are easier for SDL to apply clear color keying. Thanks for no replies hope this wil help someone.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement