Click to See Complete Forum and Search --> : Create thumbnail FILE
Bryan
May 4th, 2000, 09:58 PM
Hi, I have a Image control that already resizes my image to the desired thumbnail prepositions.
But now I need to know how to take that image and save it to a file with those dimensions.
Everything I try, I just keep resaves it like it was before I resized it.
If you can help, please do!
[Edited by Bryan on 05-05-2000 at 03:25 PM]
Fox
May 4th, 2000, 11:59 PM
Use a picturebox and stretch it with StretchBlt or PaintPicture. Then you can save it like this:
SavePicture Picture1.Image, "C:\x.bmp"
Bryan
May 5th, 2000, 12:12 AM
I have never used either of those. This is what I have tried and it doesnt seem to work.
picSave.PaintPicture imgPreview.Picture, 0, 0, imgPreview.Width, imgPreview.Height
SavePicture picSave.Image, App.Path & "\temp.bmp"
When I veiw the image I get a blank box, but its the right width and height.
Can you tell me what I am doing wrong?
[Edited by Bryan on 05-05-2000 at 01:24 PM]
kedaman
May 5th, 2000, 02:02 AM
First, don't use stretchblt, its slower than paintpicture.
I havent seen your app Bryan, but i thinks it's the same old problem people gets when they use pictures.
Just set the image property to the picture property before you handle the picture with paintpicture. Also, save the picture instead of the image.
Bryan
May 5th, 2000, 02:14 AM
Ok, now this is the code I am using, and this is what I am getting.
I have already set imgPreview and resized it and everything shows up fine.
Then I call this code to create the thumbnial.
picSave.PaintPicture imgPreview.Picture, 0, 0, imgPreview.Width, imgPreview.Height
SavePicture picSave.Picture, App.Path & "\thumbnail\" & cmbName.Text & "th.bmp"
returns:
? imgPreview.Picture
3002
?picSave.Picture
0
I have no clue what to do to fix this?
Bryan
May 5th, 2000, 02:35 AM
Ok, I have changed my code a tad. But it still doesnt work.
Dim BorderHt As Integer, BorderWd As Integer
picSave.PaintPicture imgPreview.Picture, 0, 0, imgPreview.Width, imgPreview.Height
BorderWd = picSave.Width - picSave.ScaleWidth
BorderHt = picSave.Height - picSave.ScaleHeight
picSave.Move picSave.Left, picSave.Top, imgPreview.Width + BorderWd, imgPreview.Height + BorderHt
SavePicture picSave.Image, App.Path & "\thumbnail\" & cmbName.Text & "th.bmp"
This are the results..
? imgPreview.Picture
16886
? picSave.Picture
0
? picSave.Image
3002
Any ideas??? :)
kedaman
May 5th, 2000, 02:55 AM
picsave.image=picsave.picture
Bryan
May 5th, 2000, 02:57 AM
I get a invalid use of proptery.
kedaman
May 5th, 2000, 03:33 AM
sorry, damn how stupid can i be! Put the other way round
Bryan
May 8th, 2000, 01:11 AM
Ok, here is all of the code, and when it runs, I get a Grey box as the .bmp file, the only thing that seems right is the proportions.
Private Sub SaveThumbnail()
Dim BorderHt As Integer, BorderWd As Integer
picSave.PaintPicture imgPreview.Picture, 0, 0, imgPreview.Width, imgPreview.Height
BorderWd = picSave.Width - picSave.ScaleWidth
BorderHt = picSave.Height - picSave.ScaleHeight
picSave.Move picSave.Left, picSave.Top, imgPreview.Width + BorderWd, imgPreview.Height + BorderHt
picSave.Picture = picSave.Image
SavePicture picSave.Image, App.Path & "\thumbnail\" & cmbName.Text & "th.bmp"
End Sub
These are my immediate's:
? imgPreview.Picture
16906
? picSave.Image
6194
? picSave.Picture
17978
Please can someone help me figure this out?
Thanks
--Bryan
kedaman
May 8th, 2000, 03:21 AM
Private Sub SaveThumbnail()
Dim BorderHt As Integer, BorderWd As Integer
picSave.PaintPicture imgPreview.Picture, 0, 0, imgPreview.Width, imgPreview.Height
BorderWd = picSave.Width - picSave.ScaleWidth
BorderHt = picSave.Height - picSave.ScaleHeight
picSave.Move picSave.Left, picSave.Top, imgPreview.Width + BorderWd, imgPreview.Height + BorderHt
SavePicture picSave.Picture, App.Path & "\thumbnail\" & cmbName.Text & "th.bmp"
End Sub
[Edited by kedaman on 05-09-2000 at 01:42 AM]
Bryan
May 9th, 2000, 12:51 AM
I have tried lots of code, but still doesnt work. Does anyone have an answer.
Thanks,
Bryan
kedaman
May 9th, 2000, 04:45 AM
In properties > picasve put AutoRedraw = True
Private Sub SaveThumbnail()
picsave.PaintPicture imgpreview.Picture, 0, 0, picsave.Width, picsave.Height, 0, 0, imgpreview.Width, imgpreview.Height 'Resize
SavePicture picsave.Picture, App.Path & "\thumbnail\" & cmbName.Text & "th.bmp"
End Sub
Bryan
May 9th, 2000, 09:51 PM
Ok, we are getting somewhere. Now it actually draws something, and I can see something other then a grey box when I look at the image it created. But it only draws the top left corner. Here is the code I am using
Private Sub SaveThumbnail()
picSave.PaintPicture imgPreview.Picture, 0, 0, picSave.Width, picSave.Height, 0, 0, imgPreview.Width, imgPreview.Height 'Resize
SavePicture picSave.Image, App.Path & "\thumbnail\" & cmbName.Text & "th.bmp"
End Sub
Bryan
May 9th, 2000, 09:56 PM
Ok, I got it. This is what I had to do.
Set the picSave AutoRedraw to True, then I used this code:
Private Sub SaveThumbnail()
'Set picSave's height and width
picSave.Width = imgPreview.Width
picSave.Height = imgPreview.Height
'Clear picSave
picSave.Picture = LoadPicture()
'Copy Image to picSave
picSave.PaintPicture imgPreview.Picture, 0, 0, imgPreview.Width, imgPreview.Height
'Save Picture
SavePicture picSave.Image, App.Path & "\thumbnail\" & cmbName.Text & "th.bmp"
End Sub
And it works! Thanks for all the help everyone!!!
[Edited by Bryan on 05-10-2000 at 12:00 PM]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.