Jump to content
Registration disabled at the moment Read more... ×
limelect

Bitmap and TWICImage

Recommended Posts

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

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 by limelect

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×