Followers 0

# SDL Color Key Problems

## 1 post in this topic

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.

Here is some code :

Sprite class:

class Sprite
{
private:
SDL_Surface *image;
public:
/..../
/....../
};

Somewhere in the main code:

SDL_Surface *Screen; //main screen surface
/....../
Sprite Background;
Sprite Tiles;
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
0

##### Share on other sites

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.

0

## Create an account

Register a new account

Followers 0

• 10
• 28
• 14
• 11
• 33