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
 A fixed area crop frame.
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Temoc

USA
7 Posts

Posted - Apr 23 2012 :  15:01:02  Show Profile  Reply
I need to crop face thumbnail out of photos. The thumbnails have to be 200x210 pixels at 150 dpi.
To help provide a visual aid for centering and zoom in/out the image into the crop-able area frame, I have added a layer as:
procedure ImageEnView1DrawLayerBox(Sender: TObject; ABitmap: TBitmap; layer: Integer);
TIELayer(ImageEnView1.Layers[layer]).Width := 200;
TIELayer(ImageEnView1.Layers[layer]).Height := 210;
ABitmap.Canvas.Ellipse(lLeft+lLeft1, lTop+lTop1, lRight-lRight1, lBottom-lBottom1); //the face area
ABitmap.Canvas.Rectangle(lLeft, lTop, lRight, lBottom); //the frame border


Question 1:
Is layer the correct choice for overlaying a frame which represents the area to be crop?
Question 2:
What is the proper way to zoom the image so the face fits on my frame (layer)?
ImageEnView1.ZoomIn and ImageEnView1.ZoomOut
Or
ImageEnView1.Proc.ImageResize(lCurWidth, lCurHeight, iehCenter, ievCenter);

Question 3:
How do I crop the image so that only the section that is in the frame(layer) is kept?

ImageEnView1.proc.Crop(
ImageEnView1.Layers[1].ClientAreaBox.Left,
ImageEnView1.Layers[1].ClientAreaBox.Top, ImageEnView1.Layers[1].ClientAreaBox.Right, ImageEnView1.Layers[1].ClientAreaBox.Bottom);
Question 4:
Before I call proc.crop, it seems that I have to manually click on the image so the layer gets sent back. how do I do this programmatically?

w2m

USA
1990 Posts

Posted - Apr 23 2012 :  17:49:27  Show Profile  Reply
I don't think layers is the best choice for cropping. Your face sizes will vary with each photograph so maybe your best bet is to make a preset selection, then crop and resample the image to 200,210. you could just call
// Maintain aspect ratio
ImageEnView.SelectionAspectRatio:= 1;
// Setup selection
ImageENView.SelectionOptions := [ iesoAnimated,
iesoSizeable,
iesoMoveable,
iesoFilled,
iesoCutBorders,
iesoMarkOuter,
iesoCanScroll ];
// Select
ImageENView.Select ( 0, 0, 200, 210 );
This will provide a moveable resizable selection of 200 by 210.
Allow the user to position and resize the selection and zoom if necessary.

After selecting the face, then call:
// Crop the selection
ImageENView.Proc.CropSel;
// Resample the image
ImageENView.Proc.Resample ( 200, 210, rfNone, False );

Others may have some other suggestions as well..


William Miller
Go to Top of Page

Temoc

USA
7 Posts

Posted - Apr 24 2012 :  10:51:21  Show Profile  Reply
Thank you for your quick response. We are getting closer; however I am still having an issues.
On show I set ImageEnView1.SelectionOptions := [ iesoAnimated, iesoMoveable, iesoCutBorders, iesoMarkOuter, iesoCanScroll ];

And I am defining the selectable area right after assigning the image to ImageEnView1, but I cannot drag the selected frame with the mouse.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Apr 24 2012 :  11:27:55  Show Profile  Reply

// Setup selection
ImageENView.SelectionOptions := [ iesoAnimated,
iesoSizeable,
iesoMoveable,
iesoFilled,
iesoCutBorders,
iesoMarkOuter,
iesoCanScroll ];

works for me... moveable, sizeable and selectable. I think you want iesoSizeable as well because you will need to resize the rect to fit the face and then crop and let Resample handle the aspect ratio so all your faces have the same aspect ratio and dimensions.

I tried

// Setup selection
ImageENView.SelectionOptions := [ iesoAnimated,
iesoMoveable,
iesoFilled,
iesoCutBorders,
iesoMarkOuter,
iesoCanScroll ];
as well which worked too, but then if you have different sized faces you can not change the selection to to fit the face for cropping out the face.









William Miller
Go to Top of Page

Temoc

USA
7 Posts

Posted - Apr 24 2012 :  14:55:38  Show Profile  Reply
Thank you.
I was missing the code:
ImageEnView1.MouseInteract := [miSelect];
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: