- Online Community Forums » Programming Questions » how to : Bitmap Color Mask

This thread is locked; no one can reply to it. rss feed Print
how to : Bitmap Color Mask
Member #12,838
May 2011

I have a question regarding al_convert_mask_to_alpha. I have managed to open a bitmap in an image editor and get an RGB color to feed into that funciton, but is there some way to make something easier where I do not Have to look up each color for each bitmap?

My idea was this:

al_convert_mask_to_alpha(image, al_get_pixel(image,0,0));

but al_get_pixel does not seem to return an RGB value. What does it return and is it possible to translate it into an RGB value for use in a function like this?

Edgar Reynaldo
Major Reynaldo
May 2007

If you had read the help pages linked to by your own code tags in your post, you would know al_get_pixel returns an ALLEGRO_COLOR and the second parameter of al_convert_mask_to_alpha takes an ALLEGRO_COLOR. Your code should work as far as I can tell. What isn't working? If you really need the r,g,b,a values, use one of the al_unmap_rgb* functions.

Member #12,838
May 2011

If you had read the help pages linked to by your own code tags in your post

You will have to forgive me, I am coming off Python, which is a little more verbose in the help field. I do now see that at the top of the page it defines return type. I was looking in the text for something that told me return type. I must apologize for my ignorance, also I did not realise that if I post an allegro function it links to the help page, this is an awesome resource. Thank you.

Well it appears the code I wrote up here works exactly correct!
In my actual code I had written it as:

al_convert_mask_to_alpha(player, al_get_pixel(player, al_map_rgb(al_get_pixel(player,0,0)))::)

Go to: