Reputation: 1
I have a picture box with an image associated with it.
The size mode of the PictureBox has been set to CenterImage
My question is how can I get the image co-ordinates for that underlying image.
Regards
Upvotes: 0
Views: 83
Reputation: 1799
I think your best bet is to calculate it yourself using a formula like this:
int xOffset = (pictureBox1.Width / 2) - (pictureBox1.Image.Width / 2);
int yOffset = (pictureBox1.Height / 2) - (pictureBox1.Image.Height / 2);
xOffset and yOffset should equal the (x,y) of the image from the top left corner of the picture box. Keep in mind, the formula above uses integer math and it could truncate values.
Upvotes: 2