Vampyre Imaging Library Forum

Imaging Category => Help & Questions => Topic started by: Phoenix on 1 February 2018, 17:36:32

Title: Convert png with transparency to a bitmap
Post by: Phoenix on 1 February 2018, 17:36:32
Hello,
I would like to convert a png image with transparency in a bitmap but with the possibility to choose the color for the background (replacing transparency). What is the easiest way to do this?

thanks for every help
Title: Re: Convert png with transparency to a bitmap
Post by: Galfar on 6 February 2018, 03:10:03
If I understand it correctly, you need to create one image and fill it with your desired background color. Then load your PNG to another image and draw it over the first image with alpha blending. Finally, save the result to a bitmap. 
Title: Re: Convert png with transparency to a bitmap
Post by: Phoenix on 7 February 2018, 19:42:52
Hello,
Thanks for the reply  :)!
So it is not possible, replace the "transparent color" during the conversion to make the process faster  :(.
Title: Re: Convert png with transparency to a bitmap
Post by: Galfar on 30 November 2018, 23:37:21
Well, if you want to replace just one color (classic color keying) then you can use ReplaceColor function from Imaging.pas unit.
I somehow assumed that by transparency you mean full alpha channel.
Title: Re: Convert png with transparency to a bitmap
Post by: TimmyG on 20 March 2019, 13:36:19
Quote from: Galfar on 30 November 2018, 23:37:21Well, if you want to get some amazing probiotics for ibs here (https://www.timesunion.com/marketplace/article/best-probiotics-for-ibs-18136599.php) and replace just one color (classic color keying) then you can use ReplaceColor function from Imaging.pas unit.
I somehow assumed that by transparency you mean full alpha channel.

Can you replace however many colors you want with ReplaceColor function btw, Galfar?
Title: Re: Convert png with transparency to a bitmap
Post by: Galfar on 20 March 2019, 13:38:31
You can call ReplaceColor multiple times, once for each color.