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
 Interactive Crop nightmare

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
yogiyang Posted - Sep 17 2016 : 09:14:50
Hello,

I am trying very hard to get Interactive Cropping to work properly.

But I don't understand as to why it is not working as expected.

It seems I am making some grave mistake. But I am not able to catch my mistake.

What I am trying to do is allow user to select a layer and then open a form and allow the user to crop that layer's image in the form interactively.

In the other form the image is coming very small and crop is getting set wrong and if we zoom the image using mouse wheel the crop that is set programmatically seems to dance around....

Here is the code sample along with a sample file saved using SaveAll of IEVect.

https://www.dropbox.com/s/h8g9miunq0dgl3e/InteractiveCropSample.zip?dl=0

Can someone please check this and point out my mistakes.

TIA


Yogi Yang
2   L A T E S T    R E P L I E S    (Newest First)
yogiyang Posted - Sep 19 2016 : 02:34:13
Hello Roy,

Thanks for your code sample.

It works but actually I am not able to get the crop part to locate itself accurately to the location that I want.

I have just build this sample to show the problem. But the actual code does much more. For example if there is a mask layer above currently selected layer that the crop should be set to the size of mask in the crop form.

While in your code setting the crop to the whole image is do able but what I want to implement is something like above.

TIA


Yogi Yang
rmklever Posted - Sep 17 2016 : 10:31:59
Hi,

Try not using layers in the interactive form and it will work a lot better. I got it working by doing some small changes to your source code.

Have a look at this and compare it with yours:

procedure TForm1.Button2Click(Sender: TObject);
var
  CropForm: TfrmCropPhoto;
  CropX, CropY, CropW, CropH: Integer;
  CRect: TRect;
  TotalLayers, CurrLayer: Integer;
begin
  if ImageEnVect1.IsEmpty then
    Exit;

  if ImageEnVect1.CurrentLayer.IsMask then
    Exit;

  CurrLayer := ImageEnVect1.LayersCurrent;

  CropX := 1400;
	CropY := 2390;
	CropW := 878;
	CropH := 800;

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

  CropForm := TfrmCropPhoto.Create(Application);

  CropForm.ienViewCrop.IEBitmap.Assign(ImageEnVect1.CurrentLayer.Bitmap);
  CropForm.ienViewCrop.Proc.ClearAllUndo;
  CropForm.ienViewCrop.Proc.ClearAllRedo;
  CropForm.ienViewCrop.Proc.UndoLimit := 20;

  CropForm.ienViewCrop.CropToolInteraction.SetBitmapPolygon(Rect(0, 0, CropForm.ienViewCrop.IEBitmap.Width, CropForm.ienViewCrop.IEBitmap.Height));

  CropForm.ienViewCrop.CropToolInteraction.DrawGuides := False;
  CropForm.ienViewCrop.CropToolInteraction.AntialiasMode := ierBicubic;
  CropForm.ienViewCrop.CropToolInteraction.GripSize := 12;

  CropForm.ienViewCrop.CropToolInteraction.Mode := iectmRECTANGLE;

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

  CropForm.ienViewCrop.Fit();

  if CropForm.ShowModal = mrOk then
  begin
    CropForm.ienViewCrop.CropToolInteraction.Crop;
    ImageEnVect1.CurrentLayer.Bitmap.Assign(CropForm.ienViewCrop.IEBitmap);
  end; // if CropForm.ShowModal = mrOk then

  CropForm.Free;
  ImageEnVect1.Refresh;
end;


Some code is needed to make the layer fit the new size (cropped image)...

Roy M Klever
Klever on Delphi - www.rmklever.com