Hi every one. I have the picture box in which the image may be zoomed with different values. Then I try to find out the location of cursor on picture box. I write the following code on picture box mouse move event:
int x = (2 * e.X - pictureBox1.Width + pictureBox1.Image.Width) / (2 * _scale / 100);
int y = (2 * e.Y - pictureBox1.Height + pictureBox1.Image.Height) / 2 * _scale / 100);
here _scale is is the zoomed value that may be 10,50,100,or 200 etc.
My Question:
it give the correct value if the zoomed is greater than 100%. But is the zoomed is less than 100 it give the incorrect value. How can I give the correct value if even the zoomed is less than 100% ?
Some More Explanation:
for zoomed I write the following code.
pictureBox1.Image = new Bitmap(Orignal_image, (int)( Orignal_image .Width * scale / 100), (int)( Orignal_image.Height * scale / 100));
EDIT: The size mode of picturebox is centerImage. and it is not necessary that the picturebox width is equal to the image. its width may be less than image, and then the image show at the center of picturebox. i only need the location of image. (i.e., the 0 pixel is given by start position of image not picturebox).