Alpha Channel
Marcel

Hi everyone, i'm would like to ask you, how i can load a graphic that uses alphachannels. For example this one:
[img]http://www.videogamesprites.net/SecretofMana/Party/Randi%20(Front).gif[/img]

I would be glad if anyone could help me :)

Marcel

gnolam
Quote:

Hi everyone, i'm would like to ask you, how i can load a graphic that uses alphachannels.

load_bitmap()

That picture is a GIF. GIFs have no alpha channels.

Marcel

Hi,

would it be better to use load_tga(), because I want to load an image with one invisible pixel ( sorry for alphachannel missmatching :-[ ). Or do i have to do other things first. I simply want that pallete entry 1 is invisible.

Greeting
Marcel

gnolam

If by "palette entry 1" you mean "the first palette entry" (i.e. palette index 0), then any format that Allegro can load will do. Just load as usual.

Johan Halmén

8 bit graphics:
You have a palette with 256 colours. Colour #0 can be used as transparent when blitting sprites. Each colour in the palette is defined as an 18 bit colour, not as a 24 bit colour. Creating a colour entry in the palette kind of rounds any value between 0 and 255 in any channel into a value divisible by 4. This happens in Allegro, not in your graphic editor.

24 bit graphics:
You can use any colour you get, when blending 256 shades of red, 256 shades of green and 256 shades of blue. One of these 16.7 million colours can be used as a transparent colour when blitting sprites. Magenta by default.

32 bit graphics:
Like 24 bit graphics, but 8 bit per each pixel defines the alpha channel value, which usually defines the transparency/opacity level of the pixel.

In any case you need a graphic editor that handles the graphics properly. The palette thing is usually a mess. Editors create new palettes while you are editing and they don't give a damn about you trying to preserve the entry number of each colour and especially the transparent #0. The 24 bit thing with magenta is stupid, because 24 bit usually means beautiful colours and "antialiased" contours and gradients, but the edge to the transparent magenta area is jagged like in a poor 8 bit sprite. Or even worse, you see a magenta halo around your sprite.

Read about:

  1. Blitting and sprites

  2. Transparency and patterned drawing

in the f^H manual.

Thread #591122. Printed from Allegro.cc