Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » A4 blit Equivalent

This thread is locked; no one can reply to it. rss feed Print
A4 blit Equivalent
AceBlkwell
Member #13,038
July 2011
avatar

I'm working on an old unfinished A4 project. Converting it to A5. I have a bitmap with a pink background. When I put it on the screen it remains pink. So I'm assuming the blit takes care of this. Is there a blit equivalent for A5?

Dizzy Egg
Member #10,824
March 2009
avatar

That's the old "magic pink", which was traditionally used as a mask colour.

In A5 you will need to call:

al_convert_mask_to_alpha(your_bitmap, al_map_rgb(255, 0, 255));

Where "your_bitmap" is the ALLEGRO_BITMAP* you want to create alpha for. That will turn the pink into an alpha channel.

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

AceBlkwell
Member #13,038
July 2011
avatar

Thanks Dizzy. Worked like a champ. Is there another way of making areas transparent, if "pink" is an old style approach?

DanielH
Member #934
January 2001
avatar

If it is a file you're loading then do what I do.

Open it in a paint program that can manipulate the alpha channel. Set the alpha value of the pink pixels to 0 and save it.

May have to convert to another format, not sure. I use .png for all my bitmap files.

If not then yes, this is what you do:

al_convert_mask_to_alpha(your_bitmap, al_map_rgb(255, 0, 255));

AceBlkwell
Member #13,038
July 2011
avatar

Thanks Daniel. Will that negate the need for converts or does it just change the pink to black?

DanielH
Member #934
January 2001
avatar

Only sets the alpha channel to 0. Doesn't change the r, g or b.

al_convert_mask_to_alpha
This function just converts every pixel that matches the color and sets the alpha channel to 0.

Either do it manually pre-load like I do or post-load with al_convert_mask_to_alpha.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

AceBlkwell
Member #13,038
July 2011
avatar

Gotcha, so basically building the
al_convert_mask_to_alpha(your_bitmap, al_map_rgb(255, 0, 255));
into the picture. Thanks.

Thanks Edgar. I thought pink was the only color it would work with. Didn't realize you could use other colors. Thanks

DanielH
Member #934
January 2001
avatar

Just looked at source.

al_convert_mask_to_alpha converts any pixel that matches your color to RGBA (0,0,0,0)

Go to: