[Gambas-user] Picture/Image with correct aspect ratio (G2)

Rolf-Werner Eilert eilert-sprachen at ...221...
Mon Mar 19 08:34:44 CET 2012


Never mind, Matti :-)

At least I know now my brainwork wasn't a waste of time...

Regards

Rolf

Am 17.03.2012 17:44, schrieb Matti:
> Hi Rolf,
>
> sorry - what I remembered was how I worked with thumbnails. But they have a
> fixed size, and so I could use a square PictureBox of the same size.
>
> When I have larger images and/or don't know the dimensions, I use 'stretched'
> PictureBoxes and calculate their widht/height, just like you did.
>
>
> Am 16.03.2012 10:34, schrieb Rolf-Werner Eilert:
>> Hi Matti,
>>
>> You are right, but only if the photo is as large as the PictureBox or
>> smaller. If it's larger, the photo's center will be shown, but at its
>> original size, i. e. you will see part of the photo only.
>>
>> After some fiddling, my father and I found a formular based on the size
>> of the PictureBox (133 x 133) in my program. The PictureBox is named
>> Foto, b means Width:
>>
>> DIM b, h AS Integer
>> DIM xy AS Float
>> DIM bild AS NEW Image
>>
>>        bild = Image.Load(ldsv.dateipfadModelle()&/ basisDaten[0])
>>        b = bild.Width
>>        h = bild.Height
>>        IF b>   h AND b>   133 THEN
>>          xy = b / h
>>          h = h - ((b - 133) / xy)
>>          b = 133
>>        ELSE IF h>   b AND h>   133 THEN
>>          xy = h / b
>>          b = b - ((h - 133) / xy)
>>          h = 133
>>        END IF
>>        Foto.Picture = bild.Picture
>>        Foto.Width = b
>>        Foto.Height = h
>>        Foto.Stretch = TRUE
>>
>> This way I tried it with 200 x 300 px photos in landscape and portrait,
>> everyting running perfectly. What do you think?
>>
>> Rolf
>>
>>
>> Am 15.03.2012 20:18, schrieb Matti:
>>> Hi Rolf,
>>>
>>> Square PictureBox is correct.
>>> Stretched has to be set to false.
>>> Then just set Alignment to Center (in code: 3).
>>> That's all.
>>>
>>> Matti
>>>
>>> Am 15.03.2012 10:14, schrieb Rolf-Werner Eilert:
>>>> Hi folks, this is in Gambas2:
>>>>
>>>> On a form, I have a PictureBox which shall show photos in landscape and
>>>> portrait. So I drew a square PictureBox.
>>>>
>>>> I expected that if the photo has not the same aspect ratio, it will be
>>>> shown with bars of the background color, but when I say Stretched =
>>>> True, the picture will be shown as fitted into the complete PictureBox.
>>>>
>>>> Is there any way to avoid this? Or is the only way to achieve an aspect
>>>> ratio correct display, changing the PictureBox's Height and Width?
>>>>
>>>> Thanks for your answers.
>>>>
>>>> Rolf
>>>
>>> ------------------------------------------------------------------------------
>>> This SF email is sponsosred by:
>>> Try Windows Azure free for 90 days Click Here
>>> http://p.sf.net/sfu/sfd2d-msazure
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> This SF email is sponsosred by:
>> Try Windows Azure free for 90 days Click Here
>> http://p.sf.net/sfu/sfd2d-msazure
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>





More information about the User mailing list