Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Transparent Pixel State

This thread is locked; no one can reply to it. rss feed Print
Transparent Pixel State
cheatscanner
Member #11,712
February 2010

I read that transparent pixels are the ones that are simply 0 in terms of color

I understand this, however I need to find a method to either:

Replace a specific pixel color with 0,

or

Make "color 0" pixels in Microsoft Paint.

Is 0 simply 0 red, 0 blue, 0 green, 0 alpha?

If thats the case, I might have a problem, considering MS paint doesn't deal with alpha.

How do you all do it?

-cheat

Johan Halmén
Member #1,550
September 2001

Color 0 is meaningful only in palette mode, where you have 256 colours and each of the colours is defined in the palette as a rgb entry. Color 0 would be the first entry in that palette, no matter what the rgb values for it are.

The tricky thing is not missing the alpha channel, because alpha has nothing to do with palette mode. You can have the alpha channel only in 32 bit colour mode. So in palette mode you have 256 colours. Or 255 colours and one transparent colour, in which case the transparency is on/off per pixel.

If you need a graphic editor that deals with palette mode (8 bit graphics), use Gimp or Grafx2. MSPaint or Paint.net don't let you handle the palettes, which make them useless if you draw 8 bit graphics with palette transparency. It's a pain in the donkey when you have a nice 8 bit graphic file with the palette in perfect order, then you open the file in Paint.net to edit something and Paint.net completely destroys your palette order.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This thread is obviously about nothing so heres a bunny with a pancake on its head. -kazzmir

Audric
Member #907
January 2001

This "rule" is only true for 256-color BITMAPs.
If you're using truecolor BITMAPs, in your drawing program, use the color nicknamed "magic pink" to mark transparent part: R=255 G=0 B=255. This will work for draw_sprite() and all similar functions.

And if you intend to spend any serious time drawing sprites, I'd advise to test other drawing programs. At least, be careful to NEVER try to edit 256-color images in it, such as GIF.

cheatscanner
Member #11,712
February 2010

So, "truecolor" is just 32bit, the "norm" for current technology, so to speak?, am I right?

Will it work for masked_blit function as well? Nvm, it should, considering the manual says it should >.>, stupid question.

And what is that note at the bottom of the masked_blit manual part that says it wont work on video memory without some hardware acceleration flag? Is it something I really have to be worried about? In what cases would this be applicable?

-cheat

Audric
Member #907
January 2001

the manual said:

Warning: if the hardware acceleration flag is not set, draw_sprite() will not work correctly when used with a sprite image in system or video memory so the latter must be a memory bitmap.

I don't really understand that warning (which "latter"?). I can only confirm that there's no problem when the source and destination are both in RAM, as obtained by create_bitmap(), load_bitmap(), and also through load_datafile().

For a 2D game where sprites only need full-opaque and full-transparent areas (think Metal Slug), in Allegro 4.x it's still a quite well-used method to rely on "magic pink" transparency.

8-bit palette effects are not much used anymore, but it's still mentioned a lot in Allegro docs, and the default color depth is still 8, to stay compatible with older programs.

The latest method is to rely on Alpha channel, with full RGBA pictures. It's a bit more complicated to handle IMO.

cheatscanner
Member #11,712
February 2010

Awesome, thank you for your help!

=D

I really appreciate it!

-cheat

Steve Terry
Member #1,989
March 2002
avatar

You honestly think that MS Paint supports alpha transparency? Anyway you can use pallette 0 for 256 color images or magenta for 24-bit images using paint. If you want true color alpha channel transparency you will need a different editor.

___________________________________
[ My Pictures ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

Tobias Dammers
Member #2,604
August 2002
avatar

If thats the case, I might have a problem, considering MS paint doesn't deal with alpha.

MS Paint is not to be taken seriously. It comes with windows, that's about the only advantage it has over virtually every other paint program. Other than that, it's a real pain to work with.
For free alternatives, check out Paint.NET and The GIMP. Both support alpha channels, layers, and a wide range of image file formats.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Johan Halmén
Member #1,550
September 2001

Yes, but as I pointed out, Paint.NET screws your palettes. So there's no way for you to really handle transparency in 8 bit mode with Paint.NET. And I'm afraid you can't do anything else, either. Well, you can draw one single sprite sheet for your whole game. But I don't see how you could deal with several separate sprites which should use the same palette, if you save the images as separate bmp or pcx files.

For one particular application I needed to create lots of image files, all with same palette, an 8 colour palette. In paint.NET I could reduce all my images to same 8 colours, but I couldn't control the order of the colours in the palette. For this I needed Grafx2, where I rearranged the palettes of the image files, after paint.net had shuffled them arbitrarly. Later I wrote some more code in my app where I handled the messed up palette. But this is something one shouldn't have to do.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This thread is obviously about nothing so heres a bunny with a pancake on its head. -kazzmir

Go to: