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 region outside of image
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

BillM

USA
8 Posts

Posted - Dec 04 2017 :  01:44:41  Show Profile  Reply
How do we prevent the cropping rectangle from being drawn or moved past the edges of the photo? Am I missing a setting somewhere that does this automatically?

w2m

USA
1990 Posts

Posted - Dec 04 2017 :  11:13:34  Show Profile  Reply
I do not use the croptool very much but as far as I can tell the crop tool does not have an option for this. The best that I could come up with, is to cancel the tool if its coordinates are not over the IEBitmap.
If the tool is not within the IEBitmap with this code you have to reselect to make it visible again. Perhaps Nigel may fix this problem.
procedure TForm1.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  iX: integer;
  iY: integer;
begin
  iX := ImageEnView1.XScr2Bmp(X);
  iY := ImageEnView1.YScr2Bmp(Y);
  if ((iX <= 0) or (iX > ImageEnView1.IEBitmap.Width)) then
  begin
    ImageEnView1.CropToolInteraction.Cancel();
    ImageEnView1.Deselect;
  end
  else if ((iY <= 0) or (iY > ImageEnView1.IEBitmap.Height)) then
  begin
    ImageEnView1.CropToolInteraction.Cancel();
    ImageEnView1.Deselect;
  end
  else
    ImageEnView1.MouseInteract := [miCropTool];
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

BillM

USA
8 Posts

Posted - Dec 04 2017 :  12:59:09  Show Profile  Reply
Hmmm, then is there a way to determine if the cropping rectangle is within the boundaries of the image. Let's say that I draw but them move it and the left edge extends past the left edge of the image.

If I could determine that the four edges of cropping rectangle are within the bounds of the image, then I would allow the crop to take place, otherwise I could prevent it.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Dec 04 2017 :  13:47:17  Show Profile  Reply
You can use a selection to crop instead of the crop tool and control its visibility in OnMouseMove to give you what you are looking for. Then just crop if there is a selection. This is relatively easy to accomplish.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

xequte

39053 Posts

Posted - Dec 04 2017 :  15:27:50  Show Profile  Reply
Hi

In the next update, you can use:

ImageEnView1.CropTool.Options := ImageEnView1.CropTool.Options + [iecoLimitToBounds];

You can email us for a pre-release.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: