Reputation: 61
I have an PictureBox within my Windows Form. The image mode is set to Centre Image and looks like this:
The green rectangle shows the actual size of the PictureBox, with the blue box showing how the image is displayed because of the Centre Image mode (Which is how I want it).
My question is, how do I get a position within the image (So within the blue box), where the small red rectangle represents (0,0)?
Thanks,
Lewis
Upvotes: 0
Views: 796
Reputation: 20640
You should be able to get within a pixel by calculating it:
int x = (pictureBox1.Width - pictureBox1.Image.Width) / 2;
int y = (pictureBox1.Height - pictureBox1.Image.Height) / 2;
Upvotes: 1