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
 Save/load SnapShot
 New Topic  Reply to Topic
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

xequte

38610 Posts

Posted - Jul 02 2020 :  17:09:26  Show Profile  Reply
Hi Siniša

Hmm, it sounds like it is using LoadOnDemand, but your parameters are valid.

You can use ObtainImageNow to ensure a image has been loaded.

Or try the following which will do it for you:

for i := 0 to ImageEnMView1.ImageCount - 1 do
begin
  bmp := ImageEnMView1.GetTIEBitmap( i );
  bmp.Resample(...);
  ImageEnMView1.ReleaseBitmap( i, True );
end;
ImageEnMView1.Update();


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Jul 02 2020 :  17:36:16  Show Profile  Reply
Hi Nigel,

In my previous example, I'm not using resizing at all, because "as is" is selected. As you suggested, I have tried (without resizing):


viewPbrOutput->Clear();
viewPbrOutput->ShowText = false;
viewPbrOutput->FillFromDirectory(shComboPbr->Path, -1, false, "", false, "png,PNG", false, false);
if (viewPbrOutput->ImageCount <= 0)
   return;
for (int i = 0; i < viewPbrOutput->ImageCount; i++)
   {
   viewPbrOutput->ObtainImageNow(i, true);
   }


Again, result is still the same (1,10MB) unless I scroll the mview to the bottom, then the result is 746KB. Maybe my ImageEn version is too old (8.1.1).

Edit: Saving snapshot code (ordinary TSaveDialog):


TSaveDialog *svDialog = new TSaveDialog(this);
svDialog->Filter = "Pump brush (*.pbr)|*.pbr";
svDialog->DefaultExt = "pbr";
svDialog->FileName = _dataKeeper->CommonBlock->PumpBrushDir + "Untitled";
if (svDialog->Execute())
   {
   if (viewPbrOutput->ImageCount > 0)
      {
      //NOTE: I've added these two lines befor saving snapshot  
      for (int i = 0; i < viewPbrOutput->ImageCount; i++)
	   viewPbrOutput->ObtainImageNow(i, true);
      TIESaveSnapshotOptions opt = TIESaveSnapshotOptions()<<iessoCompressed;
      viewPbrOutput->IEMBitmap->SaveSnapshot(svDialog->FileName, opt);
      }
   }
delete svDialog;


I have added two lines of code (ObtainImageNow loop) befor saving snapshot and now the file size is 1,37MB no matter if I scroll the view or not!?
All those snapshots with different sizes load normally, but I would like to get rid of size variations and somehow be able to save same snapshot with the same fixed size.

Go to Top of Page

spetric

Croatia
308 Posts

Posted - Jul 03 2020 :  16:19:33  Show Profile  Reply
Well,

I switched only to TIEMultiBitmap for loading and saving snapshots, but now I've encountered another problem.

Snapshot saved with 32-bit exe can not be read with 64-bit and vice versa:
LoadSnapshot throws exception list index out of bounds (-1), when executing.

Obviously, saving and loading snapshot is not intended for "packing" images.
I'll probably use TZipFile and zip stream with PNGs.
Go to Top of Page

xequte

38610 Posts

Posted - Jul 05 2020 :  20:21:20  Show Profile  Reply
Hi

Yes, Snapshots were designed with the idea of saving states between sessions than creating a shareable multi-image file.

32 and 64bit versions of your application cannot use Snapshot files interchangeably. We will ensure ImageEn checks for this in an upcoming update.



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