Transparency problems

Hi!
I have created a little bitmap font system, where I am blitting the
faces to the screen. The font is a bitmap with black pixels and
a pure white background (255,255,255). When I am using the
SDL_SetColorKey function like this:

SDL_SetColorKey(srfcFont,SDL_SRCCOLORKEY,SDL_MapRGB(srfcSrc->format,255,255,255));

the whole target area is filled with a black rectangle. If I’m using
instead this:

SDL_SetColorKey(srfcFont,SDL_SRCCOLORKEY,0xFFFFFFFF);

the image is blitted correctly, but too, without any kind of color keying.
Any ideas, what causes this and how to get it work correctly?

Thanks in advance,
Andreas Podgurski

Any ideas, what causes this and how to get it work correctly?
Ooops, all engines back… Just a little logic error I’ve just encountered…
Sorry! Working fine now…

Regards,
Andreas Podgurski

Hi im trying to display tiles as transparent, and it just isnt making any
colours transparent at all, here is the code im using:

loading:

temp = SDL_LoadBMP(“test.bmp”);

back = SDL_LoadBMP(“hud4.bmp”);
DrawIMG(back,0,0);
gTiles = SDL_ConvertSurface(temp, gScreen->format, SDL_SWSURFACE);

Transparent(gTiles,255,0,255);
Transparent(gScreen,255,0,255);

drawing:

void drawtile(int x, int y, int tile)
{
if (SDL_MUSTLOCK(gTiles))
if (SDL_LockSurface(gTiles) < 0)
return;
int i, j;
for (i = 0; i < 25; i++)
{
int screenofs = x + (y + i) * PITCH;
int tileofs = (i + tile * 25) * (gTiles->pitch / 4);
for (j = 0; j < 50; j++)
{
((unsigned int*)gScreen->pixels)[screenofs] =
((unsigned int*)gTiles->pixels)[tileofs];
screenofs++;
tileofs++;
}
}
if (SDL_MUSTLOCK(gTiles))
SDL_UnlockSurface(gTiles);
}

transparency:

int Transparent(SDL_Surface* Surf_Dest, int R, int G, int B) {
if(Surf_Dest == NULL) {
return 0;
}

SDL_SetColorKey(Surf_Dest, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB

(Surf_Dest->format, R, G, B));

return 1;

}

Quoting fued :

Hi im trying to display tiles as transparent, and it just isnt making any
colours transparent at all, here is the code im using:

i’m not sure i can be of much help here but as no-one has anwsered for a while
i’ll try and point you in the right direction…

you need to be absoulutley sure that the image surface you are using
has exactly
the right colour as you are trying to make transparent, and that it has a
suitable pallette / bpp depth to do so.

at a glance i cant see anything that might be wrong with your code…
but i could
be wrong :wink:

i have had issues in the past similar to this… these days i just always use
high colour png’s, and just use black, white or full pink as a mask colour.

I would suspect the problem lies with your source images.