Two questions regarding resizing images:
#1
I need to do some dynamic thumbnailing, basically, just resize a picture and save it on the fly....
Here is what I have so far:
This correctly resizes the picture in the window, but does not save it right. I know there has been some posts on this topic before, except I can't seem to get it right...Code:Private Sub Form_Load() Image1.Visible = True Image1.Stretch = True Image1.Picture = LoadPicture("c:\myPic.jpg") widt = Image1.Width higt = Image1.Height newWidt = 1500 scaler = widt / higt newHigt = CInt(1500 / scaler) Image1.Width = newWidt Image1.Height = newHigt SavePicture Image1.Picture, "c:\temp1\test.jpg " End Sub
Using Image I can set Stretch = True and the image stretches correctly, but does not save with new dimensions (I cant do the following line, which is what I would need):
Using PictureBox, I can save the new dimensions, but since there is not Stretch property, I can't get the image to look right. For instance:Code:SavePicture Image1.Image, "c:\temp1\test.jpg"
this grabs only the top corner of the image, instead of resizing it correctly....Code:Private Sub Form_Load() Picture1.Visible = True Picture1.Picture = LoadPicture("c:\myPic.jpg") widt = Picture1.Width higt = Picture1.Height newWidt = 1500 scaler = widt / higt newHigt = CInt(1500 / scaler) Picture1.Width = newWidt Picture1.Height = newHigt SavePicture Picture1.Image, "c:\temp1\test.jpg " End Sub
What's the correct way to do it??
#2
This will eventually have to become a component for ASP. My problem is that it seems that the PictureBox or Image needs the form to exist... simply doing the following:
Does not allow me to use any of PictureBox's methods... So my question is, how will have to modify this code in order for it to work as a component (without a form..) ??Code:Dim Pict As PictureBox
Thanks very much
dvst8




Reply With Quote