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
 Draw multiple selection rectangle in TImageEnView
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

quillt

India
1 Posts

Posted - Feb 08 2018 :  05:58:06  Show Profile  Reply
I want to draw multiple selection rectangles (by mouse) in a TImageEnView as shown in the picture. The rectangles will have numbers in the order in which they are created and each of the rectangles should be resizeable to adjust its area and deletable also.

xequte

38172 Posts

Posted - Feb 08 2018 :  20:11:33  Show Profile  Reply
Hi

Just use a TIEShapeLayer (optionally with a TIETextLayer for the numbers).

Please try this demo:

Demos\LayersEditing\Layers_AllTypes\Layers.dpr



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38172 Posts

Posted - Feb 11 2018 :  21:34:45  Show Profile  Reply
Alternatively, use a TIEShapeLayer with the OnDrawLayer or new OnBeforeDrawLayer event to draw the number.


// Display the index over the layer
procedure Tfmain.ImageEnView1DrawLayer(Sender: TObject; dest: TIEBitmap; LayerIndex: Integer);
var
  lyrRect, aRect: TRect;
begin
  lyrRect := ImageEnView1.Layers[ LayerIndex ].ClientAreaBox;
  aRect := Rect( lyrRect.Left + 10, lyrRect.Top + 10, lyrRect.Left + 40, lyrRect.Top + 40 );
  With dest.Canvas do
  begin
    // Simple example: Would be better to center text in filled rect
    Brush.Color := clBlue;
    FillRect( aRect );

    Font.Color  := clWhite;
    Font.Height := 12;
    Font.Style  := [fsBold];

    TextRect( aRect, lyrRect.Left + 20, lyrRect.Top + 20, IntToStr( LayerIndex ));
  end;
end;




Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: