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
 Built-in MouseIsOutsideImage function?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

933 Posts

Posted - Dec 04 2021 :  04:35:10  Show Profile  Reply
I wrote this function to detect whether the mouse pointer is outside of the image:

function TForm1.MouseIsOutsideImage(const X, Y: Integer): Boolean;
begin
  Result := (X < 0) or (Y < 0) or (X > ImageEnView1.IEBitmap.Width) or (Y > ImageEnView1.IEBitmap.Height);
end;


I use it in this way:

procedure TForm1.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  var bx := ImageEnView1.XScr2Bmp(X, False);
  var by := ImageEnView1.YScr2Bmp(Y, False);
  if MouseIsOutsideImage(bx, by) then
  begin
    DoSomething;
    EXIT; 
  end;
  var ThisColor: TColor;
  try
    ThisColor := TRGB2TColor(ImageEnView1.IEBitmap.Pixels[bx, by]);
  except
    CodeSite.Send('TForm1.ImageEnView1MouseMove except: bx', bx);
    CodeSite.Send('TForm1.ImageEnView1MouseMove except: by', by);
  end;

  DoSomething(ThisColor);
end;


Is there already a built-in MouseIsOutsideImage (or similar) function in TImageEnView? I didn't find anything in the documentation.

xequte

38613 Posts

Posted - Dec 04 2021 :  15:00:22  Show Profile  Reply
There isn't a built in function for that.

Please use:

Result := (X < 0) or (Y < 0) or (X >= ImageEnView1.IEBitmap.Width) or (Y >= ImageEnView1.IEBitmap.Height);

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

PeterPanino

933 Posts

Posted - Dec 04 2021 :  17:39:30  Show Profile  Reply
Hi Nigel,

Thanks!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: