[Gambas-user] Picture resizing?
James Hatridge
James.Hatridge at ...17...
Sun Aug 13 17:03:04 CEST 2006
HI Daniel et al..
On Saturday 12 August 2006 21:08, Daniel Campos wrote:
> If you're using a PictureBox, you can use the "Stretch" property to true,
> it will make the picture inside to fit with the dimensions of the box.
>
> Another way is to use the the Image class to process it:
>
> ....
> Dim hImg1 as Image
> Dim hImg2 as Image
>
> hImg1=Image.Load ("your path to the image")
>
> hImg2=hImg1.Stretch (newWidth, newHeight)
>
> PictureBox1.Picture=hImg2.Picture
> ....
>
> Daniel
>
> 2006/8/12, James Hatridge <James.Hatridge at ...17...>:
> > HI all...
> >
> > Ok new question! I have a picture box of about 300X400 to show my stamps.
> > For
> > most stamps its fine, but sometimes it shows only part of a larger stamp.
> > How
> > can I resize the picture (not the box) to fix inside the box?
> >
> > BTW thanks to everyone for their help, this is a great list.
OK, I got it working!
Here is the code I used:
######################
DIM hPicture AS Picture
PicName = rs!Picture
IF IsNull(PicName) THEN
PicName = "/home/hatridge/.Kstamp/Data/Pictures/default.jpg"
ELSE
PicName = "/home/hatridge/.Kstamp/Data/Pictures/" & PicName
ENDIF
hPicture = Picture[PicName]
IF hPicture.Height > 266 THEN
PictureBox1.Stretch = TRUE
PictureBox1.Picture = Picture[PicName]
ELSE
PictureBox1.Stretch = FALSE
PictureBox1.Picture = Picture[PicName]
ENDIF
#####################
The problem I had was that the field "rs!Picture" could be blank, have a small
picture, or a large picture. The "Stretch" command made the large picture fit
inside the picturebox. But it blow up the small pictures and looked bad. The
next problem was that when "rs!Picture" was blank hPicture.Height killed the
program with a NULL value error. So I fixed it so when "rs!Picture" was blank
it took a default picture. That cured the NULL value error, next I checked
the height of the picture, if it was too big for the box I turned on Stretch.
What do you guys think?
Thanks,
JIM
--
Jim Hatridge
Linux User #88484
------------------------------------------------------
WartHog Bulletin
Info about new German Stamps
http://www.fuzzybunnymilitia.org/~hatridge/bulletin/index.php
Viel Feind -- Viel Ehr'
Anti-US Propaganda stamp collection
http://www.fuzzybunnymilitia.org/~hatridge/collection/index.php
More information about the User
mailing list