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?
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.
Thanks Dizzy. Worked like a champ. Is there another way of making areas transparent, if "pink" is an old style approach?
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));
Thanks Daniel. Will that negate the need for converts or does it just change the pink to black?
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.
Don't use transparent pink, except in your old sprites, and then as everyone said, convert the mask to alpha, but make it transparent black in your paint program, or transparent white, for blending purposes.
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
Just looked at source.
al_convert_mask_to_alpha converts any pixel that matches your color to RGBA (0,0,0,0)