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
 A fixed area crop frame.

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
Temoc Posted - Apr 23 2012 : 15:01:02
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?
4   L A T E S T    R E P L I E S    (Newest First)
Temoc Posted - Apr 24 2012 : 14:55:38
Thank you.
I was missing the code:
ImageEnView1.MouseInteract := [miSelect];
w2m Posted - Apr 24 2012 : 11:27:55

// 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
Temoc Posted - Apr 24 2012 : 10:51:21
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.
w2m Posted - Apr 23 2012 : 17:49:27
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