(SOLVED) Convert PNG transparency in white color lazarus / 39-Graphics ---------------------------------------------------------------------- AsleyCruz · 2020-03-24 18:26 Hi coders, I have an PNG file with transparency in a TImage. I save it in JPG format but the transparency has black background. Is there a function to convert the transparency in white color? Many thanks a lot. ---------------------------------------------------------------------- winni · 2020-03-24 19:14 Hi! Why do you want to do that?? JPG has no transparency, it is a lossy format and with high compression it has a lousy quality. Anyway: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Uses .... BGRAbitmap, BGRAdefaultBitmap; .... var BGRA: TBGRAbitmap; beginBGRA := TBGRAbitmap.create (Image1.Picture.Bitmap);BGRA.ReplaceColor (BGRAPixelTransparent, clWhite);BGRA.Draw (Image1.Canvas,0,0);BGRA.Free;..... Winni ---------------------------------------------------------------------- lucamar · 2020-03-24 19:24 One other, maybe more simple, way (without resorting to 3rd party libs) would be to create a white TBitmap of the proper dimensions, draw the PNG over it and convert that to JPEG. ---------------------------------------------------------------------- AsleyCruz · 2020-03-24 19:45 Quote from: winni on March 24, 2020, 08:14:23 pmHi! Why do you want to do that?? JPG has no transparency, it is a lossy format and with high compression it has a lousy quality. Anyway: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ..... Winni Many thanks winni but I dont know what I am doing wrong. Please see attached image. Tested in a blank document. ---------------------------------------------------------------------- winni · 2020-03-24 20:32 Hi! Sorry - I forgot in the uses BGRAbitmapTypes; That's the whole secret. Winni ---------------------------------------------------------------------- AsleyCruz · 2020-03-24 22:49 Quote from: winni on March 24, 2020, 09:32:29 pmHi! Sorry - I forgot in the uses BGRAbitmapTypes; That's the whole secret. Winni Thanks Winni, it works and replaces transparent color of any BMP image only. Unable to replace transparent color on PNG files. Thanks ---------------------------------------------------------------------- lainz · 2020-03-24 23:05 Create a white bgrabitmap of the same size of the image. Then draw on top of it your transparent image. ---------------------------------------------------------------------- AsleyCruz · 2020-03-24 23:24 Quote from: lainz on March 25, 2020, 12:05:19 amCreate a white bgrabitmap of the same size of the image. Then draw on top of it your transparent image. Hi Lainz What I tried, it replace all red background :/ Any idea to drop the PNG file? Thanks a lot Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i BGRA := TBGRABitmap.Create(256,256,clred); ---------------------------------------------------------------------- lainz · 2020-03-24 23:49 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  bgBitmap, bgImage: TBGRABitmap; bgImage := TBGRABitmap.Create('image.png'); bgBitmap := TBGRABitmap.Create(bgImage.Width, bgImage.Height, BGRAWhite); bgBitmap.PutImage(0,0,bgImage, dmDrawWithTransparency); bg Image.Free; bgBitmap.SaveToFile('image.jpg'); bgBitmap.Free; ---------------------------------------------------------------------- AsleyCruz · 2020-03-25 00:25 Quote from: lainz on March 25, 2020, 12:49:15 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  bgBitmap, bgImage: TBGRABitmap; bgImage := TBGRABitmap.Create('image.png'); bgBitmap := TBGRABitmap.Create(bgImage.Width, bgImage.Height, BGRAWhite); bgBitmap.PutImage(0,0,bgImage, dmDrawWithTransparency); bg Image.Free; bgBitmap.SaveToFile('image.jpg'); bgBitmap.Free; Oye, tu componente es excelente, lástima no conocer bien sus capacidades. Apenas en 2 proyectos míos lo he usado, pocas líneas y grandes resultados. Mil gracias bro. ---------------------------------------------------------------------- lainz · 2020-03-25 01:46 Isn't mine. The author is circular I only contribute in bgracontrols