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
 Cropping all layers after resizing help

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
AndyColmes Posted - Sep 28 2012 : 02:19:15
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;
3   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Oct 02 2012 : 09:09:31
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
AndyColmes Posted - Oct 02 2012 : 01:54:31
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?
w2m Posted - Sep 28 2012 : 06:15:17
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