[Gambas-user] Having a bit of trouble with ImageView ZoomfFit

Cedron Dawg cedron at exede.net
Wed May 1 14:39:09 CEST 2019


"Bug or ...?  "  

Don't know.

Here is some code that accomplishes the same thing, sort of.

I say sort of, because the image viewer includes the scroll bars as part of the size.  The picture box looks nicer.


' Gambas class file

Public Sub Form_Open()

        Dim I, I2, I3 As Image
        
        I = Image.Load("~/Pictures/Wallpaper1920/DogOnDock.JPG")
        
        I2 = I.Stretch(ImageView1.W, ImageView1.H)
        ImageView1.Image = I2

        I3 = I.Stretch(PictureBox1.W, PictureBox1.H)
        PictureBox1.Image = I3

End

I hope that soothes your fury some.

Ced



----- Original Message -----
From: "adamnt42" <adamnt42 at gmail.com>
To: "user" <user at lists.gambas-basic.org>
Sent: Wednesday, May 1, 2019 7:13:54 AM
Subject: [Gambas-user] Having a bit of trouble with ImageView ZoomfFit

Basically, I have a .pic file and want to load it in an imageview 
control and then make it fit the current size of the imageview control. 
In other words, no matter what size the user has made the active form, 
the "pic" should be rescaled to fit the imageview control current size.

I am loading the imageview.image like this pseudo code:

1) user selects the object that identifies the image to load (Note the 
indirection there.)
2) code detects that a new image needs to be loaded, and
2a) calculates the path to the correct .pic file
2b) the .pic file is loaded into a Picture object - say fred
2c) (Here we go!) The imageview.image is set to fred.image
Now that all works. But now we need to rescale it to fit the curent size 
of the imageview.
I thought that (ahem) MyImageView.ZoomFit was supposed to do it.
But, the display shows it as if it was zoomed out to about 800m. IOW its 
a little block in the middle of the imageview control.
Now it gets interesting (not!). If I insert a Wait between the .image= 
and the .zoomfit of a "significant" pause then the image is rendered 
correctly. Great but pretty suboptimal.
Especially when the pause is (depending on system load) around 0.6 seconds.

This is infuriating. Totally. In fact even more infuriating than whether 
a bad memory bank switch could ever possibly result in a segfault. ( :-) )

Bug or...?
b

----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----


More information about the User mailing list