The behaviour of color key blitting seems to have changed slightly in
1.2.
I have an application where I load palettized images for which palette
color 0 should be transparent. I used to use code like this to
set per-pixel alpha=0 for indexed-color 0, and alpha=1 for all other
pixels.
SDL_Surface *orig, *rgba;
orig = IMG_Load(filename);
rgba = SDL_CreateRGBSurface(SDL_SWSURFACE, orig->w, orig->h, 32,
rmask, bmask, gmask, amask);
/* Palettized images have color index 0 transparent. We set the
* color key (transparent color) here, and fill the alpha channel
* in the dest with 0. When we do the blit the color key pixels
* aren't copied and retain the 0 alpha value. */
if (orig->format->palette != NULL) {
SDL_SetColorKey(orig, SDL_SRCCOLORKEY, 0);
SDL_FillRect(rgba, NULL, SDL_MapRGBA(rgba->format, 0, 0, 0, 0));
}
SDL_BlitSurface(orig, NULL, rgba, NULL);
Unfortunately this doesn’t seem to work in 1.2 – the alpha=0 remains
for all pixels, and is not overwritten by the SDL_BlitSurface() over
the top.
Is this a bug? A feature? Can someone suggest an alternative way of
doing what I was doing (preferably without having to code my own
pixel-test-and-set loops)?
- Mike