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
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

spetric

Croatia
308 Posts

Posted - Jun 20 2020 :  15:31:55  Show Profile  Reply
Hi,

I have a problem using SaveSnapShot/LoadSnapShot.
I'm saving snapshot from TImageEnFolderMView and trying to load it into
TImageEnMView:


....
//1. test - save snapshot from TImageEnFolderMView
if (!FolderMView1->ImageCount)
   return;
if (SaveImage1->Execute())
   {
   FolderMView1->SaveSnapshot(SaveImage1->FileName, false, true, true);
   }
....
//2. test - load snapshot into TImageEnMView
bool lRet;
if (OpenImage1->Execute())
   {
   lRet = MView1->LoadSnapshot(OpenImage1->FileName);
   }


When snapshot is saved, it's saved as some file test.pbr.
When load is called, lRet is false, file is not loaded in TImageEnMView.

Any clue, or I have a misconception about snapshot mechanism?

TIA,
Siniša



xequte

38610 Posts

Posted - Jun 21 2020 :  02:04:33  Show Profile  Reply
Hi Siniša

You cannot use TImageEnFolderMView and TImageEnMView snapshots interchangeably (I need to improve the documentation). What are you looking to achieve?

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

spetric

Croatia
308 Posts

Posted - Jun 22 2020 :  13:36:29  Show Profile  Reply
Hi Nigel,

I'm not using TImageEnLayerMView, but TImageEnMView to load snapshot.

Anyway, what I'm trying to achieve is to pack some PNGs (actually exported ABR brushes) into single file (all PNGs from one directory).

I have achieved this first by "packing" files from TImageENFolderMView:


if (!FolderMView1->ImageCount)
   return;
TMemoryStream *istream = new TMemoryStream();
for (int i = 0; i < FolderMView1->ImageCount; i++)
   {
   FolderMView1->GetImageToStream(i, istream, ioPNG);
   }
if (SaveImage1->Execute())
   {
   istream->SaveToFile(SaveImage1->FileName);
   }
delete istream;


And then I can read this file into TImageEnMView:


if (OpenImage1->Execute())
   {
   TMemoryStream *istream = new TMemoryStream();
   istream->LoadFromFile(OpenImage1->FileName);
   int i = 0;
   while (istream->Position < istream->Size)
	{
	i = MView1->AppendImage();
	MView1->SetImageFromStream(i, istream, ioPNG);
	}
   delete istream;
   }


This works OK, but I thought that using save/load snapshot would be more elegant and less lines of code.

Siniša
Go to Top of Page

xequte

38610 Posts

Posted - Jun 22 2020 :  17:08:19  Show Profile  Reply
Sorry Siniša

I meant to say that you cannot use TImageEnFolderMView and TImageEnMView snapshots interchangeably. Is there any reason you need to use both components?

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

spetric

Croatia
308 Posts

Posted - Jun 22 2020 :  17:36:49  Show Profile  Reply
Hi Nigel,

It's not necessary to use both components. If I can do what I want using TImageEnMView, it will be fine.

I need to load several transparent PNG files and create a multi-image file (transparent). Currently I've done this as described in my previous post.

So, using only TImageEnMView, I can scan selected directory/folder and
add images to TImageEnMView (or TIEMultiBitmap) and then create a snapshot.

Then I can load snapshot in TImageEnMView. Is this scenario OK?

Siniša



Go to Top of Page

xequte

38610 Posts

Posted - Jun 22 2020 :  22:02:26  Show Profile  Reply
Hi Siniša

TImageEnFolderMView descends from TImageEnMView so it can do everything, but from your description above it sounds like you only need TImageEnMView.

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

spetric

Croatia
308 Posts

Posted - Jun 23 2020 :  14:42:06  Show Profile  Reply
Hi Nigel,

I've tried using TImageEnMView:

// save snapshot
MView1->FillFromDirectory(shComboBox1->Path);
if (SaveImage1->Execute())
   {
   MView1->SaveSnapshot(SaveImage1->FileName, false, true, false);
   // no cash, compressed, no params
   }
// load snapshot
bool lRet;
if (OpenImage1->Execute())
   {
   MView1->Clear();
   lRet = MView1->LoadSnapshot(OpenImage1->FileName);
   }


...and it works.

However, when I try to load it in different TImageEnMView, it changes
ThumbWidth/ThumbHeight values.
It's not a problem to set ThumbWidth/ThumbHeight back to desired values, but I'm wondering does LoadSnapshot sets other parameters in TImageEnMView?

Thanks,
Siniša
Go to Top of Page

xequte

38610 Posts

Posted - Jun 24 2020 :  01:07:03  Show Profile  Reply
Hi Siniša

The following properties are saved:
- TImageEnMView.IEMBitmapImages
- TImageEnMIO.ParamsImage Params (meta-data) (if SaveParams=True)
- Properties of images such as TImageEnMView.ImageFileName, TImageEnMView.ImageTopText, TImageEnMView.ImageInfoText, TImageEnMView.ImageBottomText, etc
- TImageEnMView.EnableImageCachingCached images (if SaveCache=True)
- TImageEnMView.StoreType
- TImageEnMView.ThumbWidth, TImageEnMView.ThumbHeight
- TImageEnMView.UpperGap, TImageEnMView.BottomGap, TImageEnMView.LeftGap, TImageEnMView.RightGap
- TImageEnMView.TextMargin
- TImageEnMView.FilenameFilter

For TImageEnFolderMView the following are also saved:
- TImageEnFolderMView.Folder
- TImageEnFolderMView.FileTypes, TImageEnFolderMView.FileTypesMask
- TImageEnFolderMView.ExclusionMask
- TImageEnFolderMView.SortOrder, TImageEnFolderMView.SortAscending, TImageEnFolderMView.SortCaseSensitive
- TImageEnFolderMView.ShowFolders, TImageEnFolderMView.ShowHiddenFiles


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

spetric

Croatia
308 Posts

Posted - Jun 24 2020 :  17:08:38  Show Profile  Reply
Hi Nigel,

Thanks a lot for info. I've noticed that compressed snapshot takes less
space then simple "packed" PNGs. It loads a bit slower, but it's OK.

Now I can draw converted Photoshop brushes using them as brush pump/nozzle with with various options (sequential, random, selected sequential, selected random) and with various colors/textures (gives a nice result):



Again, thanks a lot.
Siniša

BTW, I hope that within a month I will be able to publish complete drawing engine with source code on GitHub.
Go to Top of Page

xequte

38610 Posts

Posted - Jun 24 2020 :  17:43:39  Show Profile  Reply
Hi Sinisa

That looks amazing. I look forward to trying out your drawing engine.



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

spetric

Croatia
308 Posts

Posted - Jun 25 2020 :  14:13:18  Show Profile  Reply
Hi Nigel,

I've played with TIEMultiBitmap, so that I don't have to show images before saving snapshot and it works well. In the other program I load TIEMultiBitmap snapshot
into TImageEnMView using:
MView1->IEMBitmap->LoadSnapshot(OpenImage1->FileName);

It works as expected.

However, when saving TIEMultiBitmap snapshot, using this code

TIESaveSnapshotOptions opt = TIESaveSnapshotOptions() << iessoCompressed;
FMMap->SaveSnapshot(SaveImage1->FileName, opt);


the size of resulting snapshot is the same regardless of TIESaveSnapshotOptions, i.e. in the case above, snapshot is not compressed.

The value of opt set (save options) is one element of value 0x01.

Am I doing something wrong?
Siniša
Go to Top of Page

xequte

38610 Posts

Posted - Jun 25 2020 :  16:55:56  Show Profile  Reply
Hi Sinisa

This works as expected for me:

   ImageEnMView1.IEMBitmap.SaveSnapshot('D:\Snap-Unc.ies', [iessoSaveIOParams] );
   ImageEnMView1.IEMBitmap.SaveSnapshot('D:\Snap-Com.ies', [iessoCompressed, iessoSaveIOParams] );




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

spetric

Croatia
308 Posts

Posted - Jun 25 2020 :  18:04:59  Show Profile  Reply
Hi Nigel,

Sorry, my mistake.

When iessoCompressed is used snapshot file size is 1,37MB
Without it (TIESaveSnapshotOptions opt = TIESaveSnapshotOptions();), it's 17,5MB.
But, when snapshot is created using TImageEnMView (compressed), it's 959KB.

With one other PNG collection (20 files), TIEMultiBitmap compressed snapshot size is 6,94MB while TImageEnMView snapshot size is 5,80MB.

I thought that using TIEMultiBitmap snapshot will be less MB then using TImageEnMView, because it does not save TImageEnMView properties.
Go to Top of Page

Vezion

2 Posts

Posted - Jun 26 2020 :  06:39:39  Show Profile  Reply
That looks really cool.
Go to Top of Page

xequte

38610 Posts

Posted - Jun 28 2020 :  03:18:57  Show Profile  Reply
Hi Siniša

What is the StoreType for your TImageEnMView?



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

spetric

Croatia
308 Posts

Posted - Jun 29 2020 :  13:15:53  Show Profile  Reply
Hi Nigel,

TImageEnMView StoreType is set to ietNormal and snapshot size is less then TIEMultiBitmap snapshot:


// test - load multibitmap
// append images to TIEMultiBitmap
FMMap = new TIEMultiBitmap(this);
int done;
String temp_str, ffil, full_str;
TSearchRec ffs;
//
ffil =  shComboBox1->Path + "\\*.png";
done = FindFirst(ffil, 32, ffs);
while (done == 0)
   {
   full_str = shComboBox1->Path + "\\" + ffs.Name;
   FMMap->AppendImage(full_str);
   done = FindNext(ffs);
   }
FindClose(ffs);
// save snapshot
if (FMMap->Count > 0)
   {
   TIESaveSnapshotOptions opt = TIESaveSnapshotOptions()<<iessoCompressed;
   if (SaveImage1->Execute())
      FMMap->SaveSnapshot(SaveImage1->FileName, opt);
   }


Anyway, I would like to pack images (PNGs) into a single file and get smallest size possible. So I'm trying with various snapshots.
Any other solution suites me as well.

Siniša
Go to Top of Page

xequte

38610 Posts

Posted - Jun 29 2020 :  23:13:29  Show Profile  Reply
Hi Siniša

I ran this code:

  // Uncompressed
  ImageEnMView1.IEMBitmap.SaveSnapshot('D:\Snap-M-Unc.ies', [iessoSaveIOParams] );
  ImageEnMView1.SaveSnapshot('D:\Snap-I-Unc.ies', False, False, True );

  // Compressed
  ImageEnMView1.IEMBitmap.SaveSnapshot('D:\Snap-M-Com.ies', [iessoCompressed, iessoSaveIOParams] );
  ImageEnMView1.SaveSnapshot('D:\Snap-I-Com.ies', False, True, True );


I got the same sizes between TImageEnMView and TIEMultiBitmap.




Turning off saving of params made no difference.

Nigel
Xequte Software
www.imageen.com

Go to Top of Page

spetric

Croatia
308 Posts

Posted - Jun 30 2020 :  13:47:12  Show Profile  Reply
Hi Nigel,

Thanks for a hint. The difference occurs between plain TIEMultiBitmap and encapsulated TIEMultiBitmap in TIenMView.

1. An example from my previous post where files are appended
to TIEMultiBitmap:


// append images to TIEMultiBitmap
FMMap = new TIEMultiBitmap(this);
int done;
String temp_str, ffil, full_str;
TSearchRec ffs;
//
ffil =  shComboBox1->Path + "\\*.png";
done = FindFirst(ffil, 32, ffs);
while (done == 0)
   {
   full_str = shComboBox1->Path + "\\" + ffs.Name;
   FMMap->AppendImage(full_str);
   done = FindNext(ffs);
   }
FindClose(ffs);
// save snapshot
if (FMMap->Count > 0)
   {
   TIESaveSnapshotOptions opt = TIESaveSnapshotOptions()<<iessoCompressed;
   if (SaveImage1->Execute())
      FMMap->SaveSnapshot(SaveImage1->FileName, opt);
   }


creates a file of 6,94MB.
While, using:


MView1->FillFromDirectory(shComboBox1->Path);
if (SaveImage1->Execute())
   {
   //MView1->SaveSnapshot(SaveImage1->FileName, false, true, false);
   TIESaveSnapshotOptions opt = TIESaveSnapshotOptions()<<iessoCompressed;
   MView1->IEMBitmap->SaveSnapshot(SaveImage1->FileName, opt);
   }


produces a file of 5,80MB.

It's more then 1MB of difference.
I can read both files correctly in TIEMultiBitmap.

In short:
TIEMultiBitmap->SaveSnapshot (example 1.) -> 6,94MB
TIenMView->IEMBitmap->SaveSnapshot (example 2.) - >5,80MB.

Both files are correctly loaded with:
TIEMultiBitmap->LoadSnapshot
TIenMView->IEMBitmap->LoadSnapshot

and both files contain 20 transparent images.




Go to Top of Page

xequte

38610 Posts

Posted - Jun 30 2020 :  19:21:41  Show Profile  Reply
Hi

Well then the question must be: Why does TImageEnMView.FillFromDirectory give a different set of images from iteratively calling TIEMultiBitmap.AppendImage?

TImageEnMView.FillFromDirectory calls TIECustomMView.SetImageFromStreamOrFile and there are a number of options that may affect the image (though by default they should be disabled), before it ultimately calls TIEMultiBitmap.AppendImage

TIEMultiBitmap.AppendImage only loads the image and appends it (no potential for image to be changed).

I haven't had time to test yet, but the difference could be the image meta-data.

You might compare:
TImageEnMView.AppendImage vs TImageEnMView.IEMBitmap.AppendImage
TIEMultiBitmap.FillFromDirectory vs TImageEnMView.FillFromDirectory


Note: To be safe, you should also be calling FillFromDirectory() with LoadOnDemand set to false:

MView1->FillFromDirectory(shComboBox1->Path , -1, False, '', False, '', False, FALSE );


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

spetric

Croatia
308 Posts

Posted - Jul 01 2020 :  16:39:16  Show Profile  Reply
Hi Nigel,

Thanks a lot.
TIEMultiBitmap.FillFromDirectory gives the same file size as
appending images to TIEMultiBitmap.

I'll use MView1->FillFromDirectory(shComboBox1->Path , -1, False, '', False, '', False, FALSE );

Works well.


Go to Top of Page

spetric

Croatia
308 Posts

Posted - Jul 02 2020 :  15:00:10  Show Profile  Reply
Hi Nigel,

It seems I really stuck on this. Here is a form:



The left view is of type TImageEnFolderMView, while right one is
TImageEnMView. Initially, when proper folder is chosen, left view is populated with PNGs (ieFastThumb) and right one is empty.

When button "Resample and convert to PBR" is pressed I load images using:

viewPbrOutput->Clear();
viewPbrOutput->ShowText = false;
viewPbrOutput->FillFromDirectory(shComboPbr->Path, -1, false, "", false, "png,PNG", false, false);


If some resizing is selected, I perform resizing:

   viewPbrOutput->LockUpdate();
   for (int i = 0; i < viewPbrOutput->ImageCount; i++)
	  {
	  // resize
	  viewPbrOutput->SelectedImage = i;
	  viewPbrOutput->Proc->Resample(rw, rh, rfLanczos3, true);
	  }
   viewPbrOutput->UnlockUpdate();


In this example (upper image), this is not the case, resizing is not performed (as is). Everything works OK, but if I don't scroll the right view, after saving the snapshot (accept button), snapshot size is 1,10MB. However, when I scroll the right view to the bottom (bottom cells are populating while scrolling) and then save the snapshot, snapshot size is 746KB.

So, my question is, how to get smaller snapshot size without scrolling?
Any way to force populating right view cells?

TIA,
Siniša

Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
Jump To: