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
 How to get size of Crop before applying it ?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
727 Posts

Posted - Sep 15 2016 :  06:50:03  Show Profile  Reply
Hello,

I am playing with the crop tool and here are the problems that I am facing:

1. How to set minimum size so that the user cannot crop an image smaller than given size.

2. How to set predefined or default size of the interactive Crop grid that is drawn we only after the user either clicks on the image or draws by dragging mouse?
Say for example there is an image which is of 1000 px width and 800 pix height. Now when the user clicks on interactive crop button I want to show a pre drawn crop area whose width is half the width of image and height is half the height of image. So in this case it width would be 500 px and height would be 400 px.

3. How to show that part of the image which will cropped in a lighter color?

4. When the user presses Enter to apply Crop how can we get the width, height and rotation of crop?

TIA


Yogi Yang

yogiyang

India
727 Posts

Posted - Sep 15 2016 :  06:53:06  Show Profile  Reply
Hello,

I have also observed if marquee selection exist then the interactive crop will not go out of selected area.

Is this by design or a bug?

TIA


Yogi Yang
Go to Top of Page

yogiyang

India
727 Posts

Posted - Sep 15 2016 :  06:56:57  Show Profile  Reply
Hello,

I missed the method SetBitmapPolygon for setting size of crop.

Sorry for this.

TIA


Yogi Yang
Go to Top of Page

yogiyang

India
727 Posts

Posted - Sep 15 2016 :  09:14:13  Show Profile  Reply
Hello,

I am using following code to set Crop area. But the crop area defined thus seem to keep on moving around randomly when we zoom the image using Scroll Wheel.

Here is the code that I am using:

var
  CropForm: TfrmCropPhoto;
  CropX, CropY, CropW, CropH : Integer;
  CRect: TRect;
  TotalLayers, CurrLayer: Integer;
begin
  if ievMain.IsEmpty then Exit;

  if ievMain.CurrentLayer.IsMask then Exit;

  //If the layer above current layer is a Mask then get its geometry
  TotalLayers := ievMain.LayersCount - 1;
  CurrLayer := ievMain.LayersCurrent;
  if ((CurrLayer + 1) <= (TotalLayers)) and (ievMain.LayersCurrent > 0) then
  begin
	CropX := 1400;
	CropY := 230;
	CropW := 878;
	CropH := 800;
  end
  else
  begin
    MessageBeep(MB_ICONERROR);
    ShowMessage('Selected Layer cannot be Cropped');
    Exit;
  end;

  CRect := Rect(CropX,CropY,CropW,CropH);

  CropForm := TfrmCropPhoto.Create(Application);

  CropForm.ienViewCrop.Layers[0].Assign(ievMain.CurrentLayer);
  CropForm.ienViewCrop.Proc.ClearAllUndo;
  CropForm.ienViewCrop.Proc.ClearAllRedo;
  CropForm.ienViewCrop.Proc.UndoLimit := 20;
  CropForm.ienViewCrop.Fit();
  CropForm.ienViewCrop.CropToolInteraction.DrawGuides := False;
  CropForm.ienViewCrop.CropToolInteraction.AntialiasMode := ierBicubic;
  CropForm.ienViewCrop.CropToolInteraction.GripSize := 12;

  CropForm.ienViewCrop.CropToolInteraction.Mode := iectmRECTANGLE;
  CropForm.ienViewCrop.Invalidate;

  CropForm.ienViewCrop.MouseInteract := [miCropTool];
  CropForm.Cursor := crIECrossSight;

  //Set the crop size and Invalidate ImageEn for the crop size to take effect
  CropForm.ienViewCrop.CropToolInteraction.SetBitmapPolygon(CRect);
  CropForm.ienViewCrop.Invalidate();
  CropForm.ienViewCrop.Fit();

  if CropForm.ShowModal = mrOk then
  begin
    //Recreate the mask with new size and then bring in the picture
    ievMain.CurrentLayer.Assign(CropForm.ienViewCrop.Layers[0]);
  end;  //if CropForm.ShowModal = mrOk then

  CropForm.Free


How to solve this problem?

TIA


Yogi Yang
Go to Top of Page

xequte

38616 Posts

Posted - Sep 15 2016 :  17:22:11  Show Profile  Reply
Hi

1. The current beta allows the LockWidth/LockHeight to apply as a minimum value only (add iecoSizeLocksAreMinimums to CropTool.Options)

2. Yes, use SetBitmapPolygon as you have done, but remember that you are passing a rect to SetBitmapPolygon, so it has Left, Top, Right, Bottom values (not with Width and Height)

3. That is not possible at this time

4. See all properties at:

http://www.imageen.com/help/TIECropToolInteraction.html

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: