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
 Saving an Image with layers Problem
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

nwscomps

190 Posts

Posted - Sep 18 2018 :  12:20:14  Show Profile  Reply
My Code:

procedure TForm1.Save1Click(Sender: TObject);
var
stream: TMemoryStream;
bLoad:boolean;
begin
SaveImageEnDialog1.AttachedImageEnIO := fCurrentIEView.IO;

stream := TMemoryStream.Create;
try
fCurrentIEView.io.SaveToStreamIEN(stream);
fCurrentIEView.LayersMergeAll(true);
if SaveImageEnDialog1.Execute then
begin
fCurrentIEView.IO.SaveToFile(SaveImageEnDialog1.FileName);
bLoad := fCurrentIEView.IO.LoadFromStreamIEN(stream);
showmessage(BoolToStr(bLoad));
end;

finally
stream.Free;
end;
end;

I am trying to save the merged version of the imageen layers by first preserving all layers into a ien stream, then saving the merged version and finally restoring all the layers from the temporary stream. But the LoadFromStreamIEN method fails and so the layers are lost in the process.
I am using the latest version.

Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library

w2m

USA
1990 Posts

Posted - Sep 18 2018 :  12:25:48  Show Profile  Reply
You have to set the position of the stream to 0 before loading it

stream := TMemoryStream.Create;
try
fCurrentIEView.io.SaveToStreamIEN(stream);
fCurrentIEView.LayersMergeAll(true);
if SaveImageEnDialog1.Execute then
begin
stream.Position := 0;
fCurrentIEView.IO.SaveToFile(SaveImageEnDialog1.FileName);
bLoad := fCurrentIEView.IO.LoadFromStreamIEN(stream);
showmessage(BoolToStr(bLoad));
end;
...

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

nwscomps

190 Posts

Posted - Sep 18 2018 :  12:32:56  Show Profile  Reply
I found the problem was the missing:
stream.seek(0,0);
to reset the position of the stream.

Francesco Savastano
Nwscomps.com
Add-ons for the ImageEn Library
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: