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
 (Colored) crosshair cursor extending to the whole image area?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

951 Posts

Posted - Oct 29 2022 :  23:42:27  Show Profile  Reply
Some graphics programs use a (colored) crosshair cursor that extends to the WHOLE IMAGE AREA, for example:



I need such a cursor for a special purpose to select an image area. Is this supported in ImageEnView?

xequte

38854 Posts

Posted - Oct 30 2022 :  17:43:34  Show Profile  Reply
Hi Peter

You can do as follows:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ImageEnView1.IO.LoadFromFile( 'D:\im.jpg' );
  ImageEnView1.ShowRulers := [ rdHorizontal, rdVertical ];
  ImageEnView1.Cursor := crNone;
end;

procedure TForm1.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
begin
  ImageEnView1.Invalidate();
end;

procedure TForm1.ImageEnView1DrawCanvas(Sender: TObject; ACanvas: TCanvas; ARect: TRect);
var
  P: TPoint;
begin
  GetCursorPos( P );
  P := ImageEnView1.ScreenToClient( P );

  ACanvas.Pen.Color := clYellow;
  ACanvas.MoveTo( P.X, 0 );
  ACanvas.LineTo( P.X, ImageEnView1.ClientHeight - 1 );
  ACanvas.MoveTo( 0, P.Y );
  ACanvas.LineTo( ImageEnView1.ClientWidth - 1, P.Y );
end;




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

PeterPanino

951 Posts

Posted - Oct 31 2022 :  05:16:35  Show Profile  Reply
Hi Nigel

Thank you for the code. It works well, although it has a certain lag when moving the mouse. (The Form with the Client-aligned ImageEnView fills the whole screen).

So I declared the MouseMove and the DrawCanvas procedures as INLINE:

procedure ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); inline;
procedure ImageEnView1DrawCanvas(Sender: TObject; ACanvas: TCanvas; ARect: TRect); inline;




But it didn't become much faster.
Go to Top of Page

xequte

38854 Posts

Posted - Oct 31 2022 :  20:07:09  Show Profile  Reply
Hi Peter

Inline should have no effect in that situation (I'm surprised the compiler does not give an error).

I don't get any performance issues with this. Though there was a typo in the code above, which I have now fixed (used bitmap sizes rather than the client).

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