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
 When Saving using LayersSaveToStream
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
728 Posts

Posted - Jan 04 2014 :  23:35:23  Show Profile  Reply
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

w2m

USA
1990 Posts

Posted - Jan 05 2014 :  07:10:52  Show Profile  Reply
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
Go to Top of Page

yogiyang

India
728 Posts

Posted - Jan 06 2014 :  04:01:38  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: