How can I accomplish this? There isn't any picturebox.image.mousemove event
that I can see. How can I translate what the picturebox gives me back to the
coordinates of the actual image underneath it? Or have I got to go about
this differently?
Thanks.
Tom
point _imgPoint;
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
_imgPoint=new Point(
(int)(((float)this.pictureBox1.Image.Width /
this.pictureBox1.Width)*e.X),
(int)(((float)this.pictureBox1.Image.Height /
this.pictureBox1.Height)*e.Y)
);
}
I didn't test it but you get the picture....
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Tom" <t...@nospam.com> wrote in message
news:ukQHF53G...@TK2MSFTNGP12.phx.gbl...
Dim _imgPoint As Point = New Point(CInt((CSng(pbImage.Image.Width /
pbImage.Width) * e.X)), CInt((CSng(pbImage.Image.Height / pbImage.Height) *
e.Y)))
This works REALLY close in stretched mode... however, as the cursor moves
either to the extreme right (width) or extreme down (height) it seems to
miss pixels. For instance, in the debugger I moved the cursor over to the
farthest point right, which should have been 2000 (since the image is 2000
pixels wide); however, with the above calculation I could only get the X
value to 1990.... It's pretty close and I guess shouldn't be too much of an
issue (if they want an exact number they will have to select to show the
image in non-stretched form) - however, is there anything else I could do to
refine this calculation to give me more precise results?
Thanks.
Tom
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:O3UWhV$GFHA...@TK2MSFTNGP14.phx.gbl...
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Tom" <t...@nospam.com> wrote in message
news:ut8btlzH...@TK2MSFTNGP14.phx.gbl...