Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
Const HALFTONE = 4
Private Sub Command1_Click()
On Error Resume Next
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End If
End Sub
Private Sub Command2_Click()
Picture2.Cls
SetStretchBltMode Picture2.hdc, HALFTONE
StretchBlt Picture2.hdc, 0, 0, 90, 120, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbSrcCopy
End Sub
Private Sub Command3_Click()
On Error Resume Next
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
SavePicture Picture2.Image, CommonDialog1.FileName
End If
End Sub
Private Sub Form_Load()
Picture1.ScaleMode = 3
Picture1.AutoSize = True
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
Picture2.ScaleMode = 3
Command1.Caption = "打开图片"
Command2.Caption = "转换"
Command3.Caption = "保存"
End Sub