If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Zoomed picture box image size.

Hi folks. I have a problem with getting the size of an image within a picture box, I'll try to explain as clearly as possible.

On a form I have a picture box, the picture box is anchored to all sides of the form and is set to zoom mode. It has to be zoom mode as I need to display very large images shrunk within the diemsions of the form.

A dialog is used to select a jpg image, which is loaded into a bitmap, the picturebox image property is then set to the bitmap object. I need to do it this way so I can keep an original copy of the image selected in memory.

The picture box correctly keeps its borders to the edge of the form and shrinks the largest dimension of the displayed image to keep the correct aspect ratio, the picture is displayed perfectly throughout form resizing.

For the sake of argument, I want to get the percentage location of a mouse click within the picture displayed, where top left is 0,0 and bottom right is 100,100.

The problem is I can't find a property within the picturebox that returns the actual size of the image displayed. I can either return the location compared to the actual size of the border, or the original image.

Re: Zoomed picture box image size.

You have two options here, and both of them are difficult...

#1).. Set the PictureBox to Normal or Center Image, and do the Image re-sizing yourself (using the Form Resize event), Taking care of all the math here is a little complicated, but very doable...(See the Crop/Zoom thread NOTE: that is VB6 Code, but the math is the same)

#2).. Just use the math and calculate the positions... Again the math is a little more complicated but also doable.. (see same thread as above for the math)..

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.