Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Alpha Channel

This thread is locked; no one can reply to it. rss feed Print
Alpha Channel
Marcel
Member #8,543
April 2007

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

--- Where the german seems to dwell... ---

gnolam
Member #2,030
March 2002
avatar

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.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Marcel
Member #8,543
April 2007

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

--- Where the german seems to dwell... ---

gnolam
Member #2,030
March 2002
avatar

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.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Johan Halmén
Member #1,550
September 2001

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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Go to: