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
 When Saving using LayersSaveToStream

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
yogiyang Posted - Jan 04 2014 : 23:35:23
Hello,

When saving image with all its layers using the function 'LayersSaveToStream' at times it only saves one single layer which is generally the Current Layer.

This happens randomly so I am not able to built a test case.

I am giving the code snippet below:
try
      CompFS := TECLFileStream.Create(SaveDialog1.FileName, fmCreate, 'testcode', eclNone);
    except on E: Exception do
      ShowMessage('Error while creating File to Save' + #13 + E.Message);
    end;

    Application.ProcessMessages;

    try
      CompFS.WriteBuffer(L, SizeOf(L));
      CompFS.WriteBuffer(Pointer(Arr)^, L * SizeOf(TItem));
    except on E: Exception do
      ShowMessage('Error while saving Data @ Stage 1' + #13 + E.Message);
    end;

    Application.ProcessMessages;

    try
      Child.ImageEnView1.LayersSaveToStream( CompFS, -1 );
    except on E: Exception do
      ShowMessage('Error while saving Data @ Stage 2' + #13 + E.Message);
    end;

    Application.ProcessMessages;

    //CompFS.Free;
    FreeAndNil(CompFS); //Free the object and set it to NIL/NULL

    Application.ProcessMessages;


TIA




Yogi Yang
2   L A T E S T    R E P L I E S    (Newest First)
yogiyang Posted - Jan 06 2014 : 04:01:38
quote:
Why are you using ProcessMessages?

I used ProcessMessages because I was getting problems while saving but after adding ProcessMessages the saving seem to take a bit more time but ultimately it does get saved properly in almost all times. Ya at times is just seems to save the whole file as a single layer file which I don't understand as to why so I posted this problem.

Thank you,


Yogi Yang
w2m Posted - Jan 05 2014 : 07:10:52
The problem probably is caused by all the Application.ProcessMessages... It is not good to use ProcessMessages. This may cause random errors. Why are you using ProceesMessages?

Are you just trying to save all layers to a file?

TImageEnView.LayersSaveToFile

Declaration

procedure LayersSaveToFile(const FileName: String; CompressionFormat: TIOFileType);

Description
LayersSaveToFile saves all layers including the bitmap, position, size, etc. in a proprietary file format. This allows TImageEnView to rebuild a previous saved configuration of layers.
All images will be compressed to the specified format, but the file which contains all layers is an ImageEn custom file format.

If CompressionFormat is -1, an internal compressed format is used. This format preserves pixel format and alpha channel.
If CompressionFormat is -2, an internal non-compressed format is used. This format preserves pixel format and alpha channel.

Note: CompressionFormat cannot be ioTIFF.

Example
// saves current layers configuration (compress images as jpeg)
ImageEnView1.LayersSaveToFile('C:\layers.lyr', -1);

// loads saved layers
ImageEnView1.LayersLoadFromFile('C:\layers.lyr');


If you are using TImageEnVect then use TImageEnVect.SaveToFileAll

Declaration
function SaveToFileAll(const fileName:string; imageCompression: TIOFileType): Boolean;

Description
Saves all layers and vectorial objects in one single file. This is like consecutive calls to LayersSaveToXXX and SaveToFileIEV.

ImageCompression specifies how compress the background image and the layers (cannot be ioTIFF).
If ImageCompression is -1, the image is saved using an internal format which preserves pixel format and alphachannel.

Note: If an internal save error is encountered Aborting will return true. Saving issues due to insufficient write permissions and disk write failures will raise an exception.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html