Create a matrix that will resize the original image into the picturebox.
new Matrix((float)pb.Width / bitmap.Width,0,0,(float)pb.Height /
bitmap.Height,0,0);
Invert the matrix and use it to backtrack the mouse coords.
See how to backtrack the mouse in Windows Forms Tips and Tricks.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com 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.
[quoted text, click to view] "Pannu" <pannu.jagwinder@yahoo.com> wrote in message
news:1429006069714a5ab2c62359bcd45b10@ureader.com...
>I have a picturebox on my VB.NET form. The picturebox size mode is set to
> stretched. I then load an image into that form and display it. As the user
> moves the mouse over the form, I want to get and display (in the status
> bar)
>
> the image coordinates of the mouse location. However, if I use the
> picturebox's MouseMove event, I am getting the coordinates of the mouse
> over
> the PICTUREBOX, not the actual image underneath that (which is stretched).
> i.e. if the actual image has a width of 2000, and I move the cursor over
> to
> the right side of the stretched picturebox image, I am only getting a left
> pixel value of around 1000 - because it is getting the mouse x:y
> coordinates
> of the picture box, not the actual image.
>
> 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.