How to deal with background transparency in sprites with Allegro 4?

Started by
2 comments, last by LennyLen 10 years, 9 months ago

I have a sprite with different background color. I want to blit this sprite into the game without its background color appearing. Is there a function to handle this type of situation in allegro 4? I know if the background is pink, it will not appear but how do I handle backgrounds of other colors?

Maybe something similar to this?

http://lazyfoo.net/SDL_tutorials/lesson05/index.php

Advertisement

I do not know Allegro so I cannot answer your first question, but the second one I can. Where you would write in the rgb values of the magenta (255, 0, 255) you would replace it with the colour you are using.

Here is a website you can use as a reference: http://www.tayloredmktg.com/rgb/

I don't think there is a way to change the mask color in Allegro 4. Why not just convert the sprite's background to the magic pink? (255, 0, 255)?


I don't think there is a way to change the mask color in Allegro 4

There isn't a function to change what the mask colour is, but you can change the Allegro source and recompile it to use whatever mask colour you want.

The mask colours are defined in the include/allegro/color.h file as such:


#define MASK_COLOR_8 0
#define MASK_COLOR_15 0x7C1F
#define MASK_COLOR_16 0xF81F
#define MASK_COLOR_24 0xFF00FF
#define MASK_COLOR_32 0xFF00FF

I've had to do this once before when I had sprites that actually contained magenta pixels.

This topic is closed to new replies.

Advertisement