Click to See Complete Forum and Search --> : Resizing images proportionately?
wchilde
Jun 1st, 2000, 03:58 AM
Is there a routine or call to resize images on a form or do
I have to do the math myself? In case this isn't clear,
setting the stretch property to TRUE deforms the image.
I want to resize it to the size of my image box yet keep
the right proportions.
parksie
Jun 5th, 2000, 02:38 AM
well, you could try setting something up like this:
Dim gfAspect as Single
Private Sub Form_Load()
gfAspect = (4 / 3) ' Screen proportions
End Sub
Private Sub MyResizer(fWidth as Single)
imgThePicture.Width = CLng(fWidth)
imgThePicture.Height = CLng(fWidth * (1 / gfAspect))
End Sub
I think that should work, but I'm not sure what you want though. If you just want to neatly stretch an Image control, then you can set the aspect, then alter the width and the height will sort itself out!
wchilde
Jun 5th, 2000, 11:06 PM
Thanks for replying. Shortly after I posted this, I went
ahead and did the math myself, doing something similar to
what you suggested. My dilema now is that changing the size
of the image and then saving it doesn't actually change
the dimensions of the saved image. I tried both with a
picture box and an image to a picture box. If I pop a msgbox
with the height and width of the image, it reflects the
modified size. But as soon as I save it, the size is back
to its original size. Any ideas?
Fox
Jun 5th, 2000, 11:13 PM
Save it's Image:
SavePicture Picture1.Image FileName
SavePicture Picture1.Picture, "C:\MyFileName.bmp"
Fox
Jun 6th, 2000, 02:50 AM
Megatron, I think that's wrong...
wchilde
Jun 7th, 2000, 01:03 AM
Tried that. It saves the same picture that loaded in
LoadPicture regardless of how I change the dimensions.
I also tried loading it into an image, changing dimensions,
then sticking it in an imagebox and saving it. Same deal.
parksie
Jun 8th, 2000, 03:36 AM
saving it in that way doesn't change the image data, only the way it's displayed. you'll need to store the larger bitmap yourself, then paint it onto the picturebox, and save to a bmp.
Fox
Jun 8th, 2000, 03:49 AM
In fact if you stretch the picture with StretchBlt you can store it's image...
No, Fox, it's right, trust me.
Fox
Jun 9th, 2000, 04:17 AM
But you don't save the stretched or redrawn picture then... just the one you loaded into the box.
kedaman
Jun 10th, 2000, 08:00 AM
Fox is right meg, image is the persistent graphics, the output of a graphics method.
Hold on, let me try it...
Yeah, it does. I guess you were right!
Fox
Jun 10th, 2000, 10:41 PM
Sure ;)
kedaman
Jun 11th, 2000, 02:28 AM
Hehe ;)
What's with the one word replies?
parksie
Jun 12th, 2000, 04:08 AM
maybe they got tired
Fox
Nov 22nd, 2000, 10:02 AM
maybe ;)
parksie
Nov 22nd, 2000, 04:46 PM
Yeah. ;)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.