Author Topic: Convert png with transparency to a bitmap  (Read 1230 times)

Phoenix

  • Guest
Convert png with transparency to a bitmap
« 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

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 372
    • View Profile
    • Galfar's Homepage
Re: Convert png with transparency to a bitmap
« Reply #1 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. 

Phoenix

  • Guest
Re: Convert png with transparency to a bitmap
« Reply #2 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  :(.

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 372
    • View Profile
    • Galfar's Homepage
Re: Convert png with transparency to a bitmap
« Reply #3 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.

Offline TimmyG

  • Imaging User
  • *
  • Posts: 1
    • View Profile
Re: Convert png with transparency to a bitmap
« Reply #4 on: 20 March 2019, 13:36:19 »
Can you replace however many colors you want with ReplaceColor function btw, Galfar?

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 372
    • View Profile
    • Galfar's Homepage
Re: Convert png with transparency to a bitmap
« Reply #5 on: 20 March 2019, 13:38:31 »
You can call ReplaceColor multiple times, once for each color.