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
 Multipage file and layers
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

graph_man

328 Posts

Posted - Oct 30 2023 :  14:48:58  Show Profile  Reply
Hello,

Is it possible to add layers to each page of a multi-page TIFF file and save it to a file so that after opening it will be possible to edit the layers on each page?

xequte

38682 Posts

Posted - Oct 31 2023 :  17:36:59  Show Profile  Reply
Hi

Not easily. There is no layer support in multi-image formats. You would need to create your own frankenformat by streaming each TIFF page with its layers to a filestream (which would not be compatible with any application other than yours).


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

graph_man

328 Posts

Posted - Oct 31 2023 :  17:40:57  Show Profile  Reply
Hi,
How to save layers in each page separately?
Go to Top of Page

xequte

38682 Posts

Posted - Oct 31 2023 :  22:58:11  Show Profile  Reply
If you want to save the layers of an image without the background image itself (to a file or stream), use:

http://www.imageen.com/help/TIOParams.IEN_StoreBackground.html

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

graph_man

328 Posts

Posted - Nov 01 2023 :  04:04:20  Show Profile  Reply
You did not understand me.
I don't want to save the layers in a separate file.
I need to save the layers in the same file as the main image.
Go to Top of Page

xequte

38682 Posts

Posted - Nov 01 2023 :  15:29:58  Show Profile  Reply
Right, well as mentioned, there are not really any good ways to do this because of the lack of multi-frame layer formats.

At simplest you could do it by streaming:

// Save the layers of three TImageEnViews to a file
var
  fs: TFileStream;
begin
  fs := TFileStream.Create(FileName, fmCreate);
  ImageEnView1.IO.SaveToStreamIEN( fs );
  ImageEnView2.IO.SaveToStreamIEN( fs );
  ImageEnView3.IO.SaveToStreamIEN( fs );
  FreeAndNil(fs);
end;

// Load the layers
var
  fs: TFileStream;
begin
  fs := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite );
  ImageEnView1.IO.LoadFromStreamIEN( fs );
  ImageEnView2.IO.LoadFromStreamIEN( fs );
  ImageEnView3.IO.LoadFromStreamIEN( fs );
  FreeAndNil(fs);
end;

But obviously that is not a very practical solution.

Another way would be to save the files to temporary IEN files and then build a single file stream from all of them. Then when loading you could iterate through the stream until you find the image index you are looking for (which would be slow with large files). Also not a great solution.

If you are certain you want to go down this route, you should store each image+layers as IEN prefixed with its size (and maybe other metadata), so when loading you could skip ahead to the image you are looking for. This way you could also replace/insert new images.

[Image 0 Stream Size]
[Image 0 Stream]
[Image 1 Stream Size]
[Image 1 Stream]
[Image 2 Stream Size]
[Image 2 Stream]
...

However that would be a much more complex undertaking.


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