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
 IEV is not able to undo LayersMergeAll...?!
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
727 Posts

Posted - Aug 15 2016 :  10:00:55  Show Profile  Reply
Hello,

I am using following code to save a file and a thumbnail image:
ievMain.SaveToFileAll('Page001.afl', -1);

  ievMain.LayersCurrent := 0; // Select Background Layer

  ShowMessage('Total Layers: ' + IntToStr(ievMain.LayersCount));

  ievMain.Proc.SaveUndo();
  ievMain.LayersMergeAll();

  //Resize merge layer image to a smaller size
  ievMain.Proc.Resample(300, -1, TResampleFilter(rfBSpline));
  ievMain.IO.SaveToFileJpeg('Page001.jpg');

  //Restore the state of ImageEnVect to state before we merged all layers
  ievMain.Proc.Undo(False);

  ievMain.UnLockUpdate;
  ievMain.Update;
  ShowMessage('Total Layers: ' + IntToStr(ievMain.LayersCount));
  ievMain.MouseInteract := [miMoveLayers, miResizeLayers];

But somehow after merging all files and saving image in jpg ImageEnVect does not seem to be able to Undo the LayersMergeAll. Or am I making any mistake in my code?

Please guide me.

TIA


Yogi Yang

w2m

USA
1990 Posts

Posted - Aug 15 2016 :  11:46:06  Show Profile  Reply
Here is a good way to achieve what you are looking for to merge all layers and objects without actually merging. This eliminates the need to have to use undo to restore layers and objects after saving the file. The original layers and objects remain intact. This technique also allows printing or print preview without eliminating layers or objects.
procedure TForm1.SaveAll1Click(Sender: TObject);
var
  iImageEnView: TImageEnView;
begin
  iImageEnView := TImageEnView.Create(nil);
  try
    { Draw the layers to iImageEnView }
    ImageEnVect1.UnSelAllObjects;
    { Draw the layers and objects to iImageEnView }
    ImageEnVect1.LayersDrawTo(iImageEnView.IEBitmap);
    iImageEnView.Update;
    {Resample the iImageEnView}
    iImageEnView.Proc.Resample(300, -1, TResampleFilter(rfBSpline));
    { Save the image}
    iImageEnView.IO.SaveToFileJpeg('G:\Scrap\MergeAll.jpg');
  finally
    iImageEnView.Free;
  end;
end;

procedure TForm1.Print1Click(Sender: TObject);
var
  iImageEnView: TImageEnView;
begin
  iImageEnView := TImageEnView.Create(nil);
  try
    { Draw the layers and objects to iImageEnView }
    ImageEnVect1.LayersDrawTo(iImageEnView.IEBitmap);
    iImageEnView.Update;
    iImageEnView.IO.DoPrintPreviewDialog();
  finally
    iImageEnView.Free;
  end;
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

yogiyang

India
727 Posts

Posted - Aug 16 2016 :  02:54:12  Show Profile  Reply
Hello Bill,

Thanks for the code sample. I will use it and get back to you if necessary.

TIA


Yogi Yang
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: