adjusting window (and image view) sizes to the dimension of the image

Hi All,

I did a search on this topic and the one that came closest to my question is this:

The above thread would have been perfect except that it did not reach a definitive end to clearly resolve the issue in question - how to adjust the window size (along with the image view inside that window) to the dimensions of the image to be displayed.

I got as far as jobu’s codes to extract the dimension of the image to be displayed - that’s not a problem. The problem is how to adjust the size of the window cum image view to the size of the images that vary in sizes. When I try to alter the size of the window to the size of the current image, the window expands to a size that is even bigger than the original window that the IB created. It seems from this that the window created by the IB has a different scale from the image that is being displayed but then again, it seems odd that the container would have a different scale than the object that it displays. No?

Would greatly appreciate any lead/suggestion/tip on what I can do to match the dimensions of the window (with the image view) to the actual dimension of the images to be displayed.


archseed :frowning:

HI Again,

Further to this post →

I tried to adjust the window size to the image size using the “bounds” property with the origin at {0, 0} if that is important to the topic. What I changed are only the width and height values and made them equal to the corresponding values of the current image. When I did that, that’s when the big size of window (and the image view) came up. I can therefore alter the size of the window (and presumably the image view inside it) but I could not make it conform ideally to the image dimension.


archseed :slight_smile:

Hi All,

Here’s a further update on my “trial-error” experimentation.

Whenever I change the points of origin of the window, for instance from {0,0} to {40, 40}, the window changes position but the image view it contains does not dynamically adjust - the edges of the image view gets clipped off. It seems to be static. In order to adjust the window to the image view, I need to adjust the corresponding width and height of the window as well.

Unfortunately, I could not find any property in image view documentation that can be changed. If there is a way to change the seemingly static image view, then it should be adjustable to the dimension of the image to display (and the window that contains it) once you have the latter values determined.

Anybody has any suggestion/tip/advise to offer?


archseed :frowning: