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
 Cropping all layers after resizing help
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndyColmes

USA
351 Posts

Posted - Sep 28 2012 :  02:19:15  Show Profile  Reply
I have layer 0 and layer 1 in a TImageEnVect. Layer 1 is resizeable and moveable. The following code to crop does not seem to work after the layer 1 is resized or moved. It crops the layer 1 like it was before the resizing. Where did I go wrong?

if MainImageEnVect.Selected then begin

MainImageEnVect.SaveSelection;
for i := MainImageEnVect.LayersCount - 1 downto 0 do begin
MainImageEnVect.LayersCurrent := i;
MainImageEnVect.RestoreSelection ( false, iersSyncLayers} );
MainImageEnVect.Proc.CropSel;
MainImageEnVect.CurrentLayer.PosX := 0;
MainImageEnVect.CurrentLayer.PosY := 0;
end;
MainImageEnVect.DiscardSavedSelection;
MainImageEnVect.MouseInteract := [ miMoveLayers, miResizeLayers ];
MainImageEnVect.Cursor := crHandPoint;
for i := 0 to MainImageEnVect.LayersCount - 1 do begin
MainImageEnVect.Layers [ i ].PosX := 0;
MainImageEnVect.Layers [ i ].PosY := 0;
MainImageEnVect.Layers [ i ].Width := MainImageEnVect.Layers [ i ].Bitmap.Width;
MainImageEnVect.Layers [ i ].Height := MainImageEnVect.Layers [ i ].Bitmap.Height;
end;
end else begin
//'No Selection to Crop';
end;

end;

w2m

USA
1990 Posts

Posted - Sep 28 2012 :  06:15:17  Show Profile  Reply
I tried your code.

After moving a layer its dimensions remains the same as it was before it was moved. If you resize a layer with the mouse the image is stretched to fit the layers dimensions.

It is operating like it should. I do not see any change in the bitmaps dimensions (it remains cropped) when moving the layer.

You probably have some code else where, (maybe in ImageEnVect1LayerNotify) that changes things.

What is your objective? As it is written the code crops the image in each layer to the same dimensions then positions each layer at the same location and sets each layers dimensions to be the same. Is this what you want?

If you do not want resizing then just setMouseInteract to miMoveLayers:
MainImageEnVect.MouseInteract := [miMoveLayers];

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

AndyColmes

USA
351 Posts

Posted - Oct 02 2012 :  01:54:31  Show Profile  Reply
If the layer 1 is resized using miResizeLayers, for example to fit the size of the layer 0, making a selection after that (which seems to be on the layer 1) and cropping does not crop layer 0 correctly. Layer 1 is cropped correctly. Is there a necessity to translate the selection to the layer 0 due to the resizing of layer 1?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Oct 02 2012 :  09:09:31  Show Profile  Reply
Andy,

I am not understanding what you want to do. Send me a small demo and I'll look at it.

Meanwhile you can try this:
procedure TForm1.CropAllLayers1Click(Sender: TObject);
var
  i: integer;
begin
  if ImageEnVect1.Selected then
  begin
    ImageEnVect1.SaveSelection;
    // Crop each layer
    for i := ImageEnVect1.LayersCount - 1 downto 0 do
    begin
      ImageEnVect1.LayersCurrent := i;
      ImageEnVect1.RestoreSelection(false, iersSyncLayers);
      ImageEnVect1.Proc.CropSel;
      ImageEnVect1.CurrentLayer.PosX := 0;
      ImageEnVect1.CurrentLayer.PosY := 0;
    end;
    ImageEnVect1.DiscardSavedSelection;
    ImageEnVect1.MouseInteract := [miMoveLayers, miResizeLayers];
    ImageEnVect1.Cursor := crHandPoint;
    ImageEnVect1.DeSelect;
  end
  else
    MessageBox(0, 'No Selection to Crop', 'Warning', MB_ICONWARNING or MB_OK);
end;

Now after cropping the image you resize Layer 1 with the mouse the image in layer 1 will be stretched to fit the bounds of the layer.
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: