T O P I C R E V I E W |
spetric |
Posted - Jun 20 2020 : 15:31:55 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
|
20 L A T E S T R E P L I E S (Newest First) |
xequte |
Posted - Jul 05 2020 : 20:21:20 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
|
spetric |
Posted - Jul 03 2020 : 16:19:33 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. |
spetric |
Posted - Jul 02 2020 : 17:36:16 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.
|
xequte |
Posted - Jul 02 2020 : 17:09:26 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
|
spetric |
Posted - Jul 02 2020 : 15:00:10 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
|
spetric |
Posted - Jul 01 2020 : 16:39:16 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.
|
xequte |
Posted - Jun 30 2020 : 19:21:41 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
|
spetric |
Posted - Jun 30 2020 : 13:47:12 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.
|
xequte |
Posted - Jun 29 2020 : 23:13:29 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
|
spetric |
Posted - Jun 29 2020 : 13:15:53 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
|
xequte |
Posted - Jun 28 2020 : 03:18:57 Hi Siniša
What is the StoreType for your TImageEnMView?
Nigel Xequte Software www.imageen.com
|
Vezion |
Posted - Jun 26 2020 : 06:39:39 That looks really cool. |
spetric |
Posted - Jun 25 2020 : 18:04:59 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. |
xequte |
Posted - Jun 25 2020 : 16:55:56 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
|
spetric |
Posted - Jun 25 2020 : 14:13:18 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 |
xequte |
Posted - Jun 24 2020 : 17:43:39 Hi Sinisa
That looks amazing. I look forward to trying out your drawing engine.
Nigel Xequte Software www.imageen.com
|
spetric |
Posted - Jun 24 2020 : 17:08:38 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. |
xequte |
Posted - Jun 24 2020 : 01:07:03 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
|
spetric |
Posted - Jun 23 2020 : 14:42:06 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 |
xequte |
Posted - Jun 22 2020 : 22:02:26 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
|
|
|