ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Problem with TImageEnIO.Bitmap after update from Version9 to 12
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Speedy_08

Germany
3 Posts

Posted - Jun 12 2023 :  08:21:59  Show Profile  Reply
Hello,

I have updated from version 9 to 12. Unfortunately, after the update, my code no longer works as desired.

i my case i paint some things to a bitmap and try to save it in 2 different formats.
Unfortunately, when save,
i get the message that there is no valid image in the function CheckHaveValidBitmap.
With Version 9.x ist runs without problems.
OK, i create and use only an TBitmap instead of an IEBitmap.
How can i handle this in version 12?


my Code:

var
 myBMP: TImageENIO;
begin
 try
  myBMP := TImageENIO.Create(self);
  myBMP.Bitmap := TBitmap.Create;
  myBMP.Bitmap.PixelFormat := pf8bit;
  myBMP.Params.JPEG_Quality := 100;
  myBMP.Bitmap.Height := 500;
  myBMP.Bitmap.Width := 500;
  PaintLines(myBMP.Bitmap);
//Crash with Error "Bitmap not valid"
  myBMP.SaveToFileJPEG(Temp_Path + Pict_Filenames + '.jpg');
  myBMP.SaveToFilePNG(Temp_Path + Pict_Filenames + '.png');
  myBMP.Bitmap.Free;
  FreeAndNil(myBMP);
end;

xequte

38683 Posts

Posted - Jun 12 2023 :  12:37:24  Show Profile  Reply
Hi

Please use AttachedBitmap (or CreateFromBitmap) rather than setting the Bitmap property:

http://www.imageen.com/help/TImageEnIO.AttachedBitmap.html
http://www.imageen.com/help/TImageEnIO.CreateFromBitmap.html

var
  myBMP: TBitmap;
  myIO: TImageEnIO;
begin
  myBMP := TBitmap.Create;
  myBMP.PixelFormat := pf8bit;
  myBMP.Height := 500;
  myBMP.Width := 500;
  PaintLines(myBMP);

  myIO := TImageEnIO.CreateFromBitmap( myBMP );
  myIO.Params.JPEG_Quality := 100;
  myIO.SaveToFileJPEG(Temp_Path + Pict_Filenames + '.jpg');
  myIO.SaveToFilePNG(Temp_Path + Pict_Filenames + '.png');
  FreeAndNil(myIO);  

  myBitmap.Free;
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: