limelect 53 Posted 20 hours ago Out of curiosity, I have 2 functions, one OK, the other not 2 exact function, the PNG returns a white picture, the TIFF works procedure BITMAPtoPNG2(MyBitmap: TBitmap; destinationfilename: string); var MyWIC: TWICImage; // preserves transparency begin // Assert( MyBitmap.PixelFormat := pf32bit; << it was 24 same result MyWIC := TWICImage.Create; try MyBitmap.AlphaFormat := afDefined; MyWIC.LoadFromFile(FileSave); <<<<<<<<<<<<<<<<<<<<<<I have to do that // MyWIC.Assign(MyBitmap); <<<<<<<<<<<<<<<<<<<<<<< this return white picture MyWIC.ImageFormat :=TWICImageFormat.wifPng ;//wifPng; if Form1.TestIfFileExist(destinationfilename) then MyWIC.SaveToFile(destinationfilename); finally MyWIC.Free; end; end; THIS IS OK procedure BITMAPtoTIFF(MyBitmap: TBitmap; destinationfilename: string); var MyWIC: TWICImage; begin MyWIC := TWICImage.Create; try MyWIC.Assign(MyBitmap); <<<<<<<<<<<<< This is OK MyWIC.ImageFormat := TWICImageFormat.wifTiff; if Form1.TestIfFileExist(destinationfilename) then MyWIC.SaveToFile(destinationfilename); finally MyWIC.Free; end; end; Share this post Link to post
limelect 53 Posted 19 hours ago (edited) I fixed it by bringing b := TBitmap.Create; b.Assign(ImgView321.Bitmap); Send B to functions However, if I load b from a file, it does not work. (MyBitmap) I still wonder. Any explanation? Edited 19 hours ago by limelect Share this post Link to post
Anders Melander 2050 Posted 18 hours ago TBitmap.AlphaFormat is broken beyond repair - literally. See: https://quality.embarcadero.com/browse/RSP-26621 If you need to handle 32-bit RGBA bitmaps, use something that was designed for it. Share this post Link to post
limelect 53 Posted 18 hours ago (edited) Thanks, I thought so As you can see, I fixed it differently Edited 18 hours ago by limelect Share this post Link to post
DelphiUdIT 257 Posted 17 hours ago 1 hour ago, Anders Melander said: TBitmap.AlphaFormat is broken beyond repair - literally. See: https://quality.embarcadero.com/browse/RSP-26621 Share this post Link to post
Remy Lebeau 1636 Posted 14 hours ago Why use TWICImage and not TPNGImage? Share this post Link to post