Results 1 to 1 of 1

Thread: [2.0] SizeMode.Zoom, how much did it stretch?

  1. #1

    Thread Starter
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502

    [2.0] SizeMode.Zoom, how much did it stretch?

    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:
    Code:
    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
    Last edited by BramVandenbon; Jun 13th, 2007 at 10:45 PM. Reason: forgot the title
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width