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
 Custom draw crop box

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Size 
UserName:
Password:
Mode 
Format  BoldItalicizedUnderline Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailBrowse for an image to attach to your post Browse for a zip to attach to your post Insert CodeInsert QuoteInsert List
   
Message 

 

Smilies
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
hifly Posted - Jun 19 2019 : 21:22:38
HI.

I am doing portrait collection, using IMAGEEN image component.
Now there is a problem that needs your help to solve.




5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jun 23 2019 : 21:15:20
Hi

Please take a look at crop tool demo, it shows locking the crop box:

Demos\ImageEditing\CropTool\CropTool.dpr

Nigel
Xequte Software
www.imageen.com
hifly Posted - Jun 23 2019 : 09:07:25
@xequte
Thanks for your help. There are two more problems to be solved.
1. How to set the size of the clipping box? (X, Y, Width, Height)
2. Lock the cutting ratio according to the size of the sheet? (Width, Height)
xequte Posted - Jun 19 2019 : 22:49:26
And here is the demo:

attach/xequte/201961922180_SelectAndCrop2.zip
2789.69 KB

Nigel
Xequte Software
www.imageen.com
xequte Posted - Jun 19 2019 : 22:49:08
Another example:


// Draw "thirds" within the selection box
procedure TForm1.ImageEnView1DrawCanvas(Sender: TObject; ACanvas: TCanvas; ARect: TRect);
var
  selRect: TIERectangle;
  {}
  procedure _DrawLine(x1, y1, x2, y2: Integer); // bmp values
  begin
    ACanvas.Pen.Color := clGray;
    ACanvas.MoveTo( ImageEnView1.XBmp2Scr( x1 ), ImageEnView1.YBmp2Scr( y1 ) );
    ACanvas.LineTo( ImageEnView1.XBmp2Scr( x2 ), ImageEnView1.YBmp2Scr( y2 ) );
  end;
  {}
begin
  if not ( ImageEnView1.Selected and chkDrawBox.Checked ) then
    exit;

  selRect := ImageEnView1.SelectedRect;

  // Horz Thirds
  _DrawLine( selRect.x, selRect.y + MulDiv( selRect.height, 1, 3 ),
             selRect.x + selRect.Width, selRect.y + MulDiv( selRect.height, 1, 3 ) );
  _DrawLine( selRect.x, selRect.y + MulDiv( selRect.height, 2, 3 ),
             selRect.x + selRect.Width, selRect.y + MulDiv( selRect.height, 2, 3 ) );

  // Vert Thirds
  _DrawLine( selRect.x + MulDiv( selRect.Width, 1, 3 ), selRect.y,
             selRect.x + MulDiv( selRect.Width, 1, 3 ), selRect.y + selRect.height );
  _DrawLine( selRect.x + MulDiv( selRect.Width, 2, 3 ), selRect.y,
             selRect.x + MulDiv( selRect.Width, 2, 3 ), selRect.y + selRect.height );
end;



Nigel
Xequte Software
www.imageen.com
xequte Posted - Jun 19 2019 : 22:18:25
Hi

You can custom draw on the image view using the OnDrawCanvas event:


// Show a 100x100px box in the center of the image (does not modify the actual image, only the view)
procedure TForm1.ImageEnView1DrawCanvas(Sender: TObject; ACanvas: TCanvas; ARect: TRect);
const
  Box_Width  = 100;
  Box_Height = 100;
var
  boxL, boxT, boxR, boxB: Integer;
begin
  if ImageEnView1.IsEmpty2 or
     ( ImageEnView1.IEBitmap.Width < Box_Width ) or
     ( ImageEnView1.IEBitmap.Height < Box_Height ) or
     not chkDrawBox.Checked then
    exit;

  boxL := ImageEnView1.XBmp2Scr( ImageEnView1.IEBitmap.Width  div 2 - Box_Width  div 2 );
  boxT := ImageEnView1.YBmp2Scr( ImageEnView1.IEBitmap.Height div 2 - Box_Height div 2 );
  boxR := ImageEnView1.XBmp2Scr( ImageEnView1.IEBitmap.Width  div 2 + Box_Width  div 2 );
  boxB := ImageEnView1.YBmp2Scr( ImageEnView1.IEBitmap.Height div 2 + Box_Height div 2 );

  ACanvas.Pen.Color := clRed;
  ACanvas.Brush.Style := bsClear;
  ACanvas.Rectangle( boxL, boxT, boxR, boxB );
end;


Nigel
Xequte Software
www.imageen.com