Hi,
I have some .pcx images with black background. And want to draw this images with the black transparent.
I could use al_convert_mask_to_alpha but the black color is not exactly (0,0,0) it could be (0,1,0) etc.
How set transparency to this black background of pcx images?
I using al_draw_bitmap_region() to draw bitmap. A5.
Thank you.
al_convert_mask_to_alpha is the only thing Allegro offers to do this. I've found a Windows(tm) tool called Greenfish Icon Editor to be great for removing backgrounds though. It has a "Remove Matte" function which will turn the black to alpha... not guaranteed to work but for me it did.
I've attached a command line utility you can use to convert the near-black pixels in your images to black pixels. Press SPACE to increase the tolerance value it uses to replace pixels and S to save. ESC exits the program.
Each pass through, any pixels that are converted are made transparent on a copy of the image which is then drawn over a light blue background. This will allow you to still see any dark background pixels that haven't been converted to black yet.
Here's the code (Allegro 4):
You could, dunno, batch-edit your pictures to replace black pixels with zero alpha.
Just use Paint.net or Gimp to flood fill black with a high (20% tolerance) - that should give you a decent edge.
You could, dunno, batch-edit your pictures to replace black pixels with zero alpha.
PCX doesn't support alpha.
I've implemented your code in my Draw function.
And it works.
Thank you.
Ok, but be sure too realize that it wasn't designed to be used during the running of the game itself, and it could slow your drawing down considerably.
The intended use is for you to go over all the graphics you do have and replace them so that you can use them in your game without having to modify them at runtime.