Alex.
Retired
- Joined
- Aug 24, 2005
- Messages
- 4,616
Hi, a while ago I came upon this issue and ignored it, but now I really need to know how to get to the bottom of this:
CODE
// assume a 16-bit "sprite" surface, with a loaded image
// the mask colour is purple (255, 78, 207)
SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, SDL_MapRGB(sprite->format, 255, 78, 207));
// create a surface
s = SDL_CreateRGBSurface(SDL_SWSURFACE, sprite->w, sprite->h, sprite->format, 0, 0, 0, 0);
// blit the sprite on it
SDL_BlitSurface(sprite, NULL, s, NULL);
// set the surface's alpha to 50%
SDL_SetAlpha(s, SDL_SRCALPHA, 128);
// blit the surface to the screen
SDL_BlitSurface(s, NULL, screen, NULL);
The problem is that the mask colour is also drawn to the screen, at the certain alpha I set the whole surface to. I know there has to be a way around this, any help would be greatly appreciated Thanks!
Edit: I got it to work, sorry for the idiotic question :X (solution posted below)
CODE
// assume a 16-bit "sprite" surface, with a loaded image
// the mask colour is purple (255, 78, 207)
SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, SDL_MapRGB(sprite->format, 255, 78, 207));
// create a surface
s = SDL_CreateRGBSurface(SDL_SWSURFACE, sprite->w, sprite->h, sprite->format, 0, 0, 0, 0);
// blit the sprite on it
SDL_BlitSurface(sprite, NULL, s, NULL);
// set the surface's alpha to 50%
SDL_SetAlpha(s, SDL_SRCALPHA, 128);
// blit the surface to the screen
SDL_BlitSurface(s, NULL, screen, NULL);
The problem is that the mask colour is also drawn to the screen, at the certain alpha I set the whole surface to. I know there has to be a way around this, any help would be greatly appreciated Thanks!
Edit: I got it to work, sorry for the idiotic question :X (solution posted below)