|
-
Jun 27th, 2000, 02:58 AM
#3
_______
...walk around....
'here is how I would do it...
'load your picture into a picture box that is set to invisible
'save your picture and then load the saved picture into the image
'control.
'One big drawback...VB controls save the picture as a bmp
'regardless of the format of the original picutre..
'
'there is an article on saving jpgs here
' http://vbaccelerator.com/codelib/gfx/vbjpeg.htm
'good luck...
Option Explicit
Const MAX_SIZE = 1500 'Twips
Private Sub Command1_Click()
Dim h As Long
Dim w As Long
Dim pic As StdPicture
On Error GoTo THUMBERR
'Get the picture loaded in picSrc
'or load a picture using the "Open" dialog box
Set pic = picDst.Picture
'Make sure we have a picture
If pic = 0 Then Exit Sub
'Convert the height and width to twips
h = ScaleY(pic.Height, vbHimetric, vbTwips)
w = ScaleX(pic.Width, vbHimetric, vbTwips)
'Scale the destination picturebox to maintain
'the same aspect ratio as original picture
'but have max dimension of MAX_SIZE
With picDst
If w > h Then
.Width = MAX_SIZE
.Height = (h / w) * MAX_SIZE
Else
.Height = MAX_SIZE
.Width = (w / h) * MAX_SIZE
End If
'Clear previous image and picture
.Cls
.Picture = LoadPicture("")
'Scale the picture into the destination picbox
.PaintPicture pic, 0, 0, .Width, .Height, 0, 0, w, h, vbSrcCopy
'Convert the drawn image to the picture
Set .Picture = .Image
'Optionally save with "Save As" dialog box:
SavePicture .Picture, "c:\anewpicture.bmp"
End With
'Clear the pic object
Set pic = Nothing
Set Image1.Picture = LoadPicture("c:\anewpicture.bmp")
Exit Sub
THUMBERR:
MsgBox Err.Description
Err.Clear
End Sub
Private Sub Form_Load()
picDst.Visible = False
picDst.ScaleMode = 1 'Twip
picDst.AutoRedraw = True
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|