BramVandenbon
Jun 13th, 2007, 10:37 PM
Hi,
when you set the SizeMode property of the picturebox to PictureBoxSizeMode.Zoom, then the Width and Height properties of the image are not affected by the stretching. They still hold the values of the original image, because the image did not change, only the presentation. Is there a quick way to find out the displayed sizes though?
I guess I could just calculate it as followed:
float factor = 0;
if ((float)picturebox.Width/(float)pictureBox.Height > (float)image.Width/(float)image.Height)
factor = (float)picturebox.Width/(float)image.Width;
else
factor = (float)picturebox.Height/(float)image.Height;
int DisplayedWidth = (int)((float)image.Width * factor);
int DisplayedHeight = (int)((float)image.Height * factor); (I did not test this code, but that's what comes to my mind at first sight)
But my guess is that I do not need to calculate this, I assume there's some property somewhere which holds these values. Is there?
Greetings
BramGo
when you set the SizeMode property of the picturebox to PictureBoxSizeMode.Zoom, then the Width and Height properties of the image are not affected by the stretching. They still hold the values of the original image, because the image did not change, only the presentation. Is there a quick way to find out the displayed sizes though?
I guess I could just calculate it as followed:
float factor = 0;
if ((float)picturebox.Width/(float)pictureBox.Height > (float)image.Width/(float)image.Height)
factor = (float)picturebox.Width/(float)image.Width;
else
factor = (float)picturebox.Height/(float)image.Height;
int DisplayedWidth = (int)((float)image.Width * factor);
int DisplayedHeight = (int)((float)image.Height * factor); (I did not test this code, but that's what comes to my mind at first sight)
But my guess is that I do not need to calculate this, I assume there's some property somewhere which holds these values. Is there?
Greetings
BramGo