Jump to content

  • Log In with Google      Sign In   
  • Create Account


SDL Color Key Problems


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 aliasc   Members   -  Reputation: 180

Like
0Likes
Like

Posted 03 February 2014 - 04:50 PM

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, 03 February 2014 - 04:52 PM.


Sponsor:

#2 aliasc   Members   -  Reputation: 180

Like
0Likes
Like

Posted 04 February 2014 - 10:43 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS