ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Saving an Image with layers Problem

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
nwscomps Posted - Sep 18 2018 : 12:20:14
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
2   L A T E S T    R E P L I E S    (Newest First)
nwscomps Posted - Sep 18 2018 : 12:32:56
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
w2m Posted - Sep 18 2018 : 12:25:48
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