VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)

VB爱好者乐园(VBGood)

 找回密码
 立即注册
搜索
查看: 1242|回复: 0

picture缩略图调用出现 参数不可选

[复制链接]
发表于 2015-11-12 11:29:35 | 显示全部楼层 |阅读模式
本帖最后由 asd888 于 2015-11-13 10:16 编辑


源代码

Sub GdipLoadZoomImage(strFileName As String, PBox As PictureBox)
On Error Resume Next
Dim gdip_Token As Long
Dim gdip_Image As Long
Dim gdip_Graphics As Long
Dim lRet As Long
Dim iW As Long
Dim iH As Long
Dim pW As Single
Dim pH As Single
Dim GpInput As GdiplusStartupInput
GpInput.GdiplusVersion = 1
If GdiplusStartup(gdip_Token, GpInput) <> 0 Then Exit Sub
PBox.Cls
GdipLoadImageFromFile StrPtr(strFileName), gdip_Image
GdipGetImageWidth gdip_Image, iW
GdipGetImageHeight gdip_Image, iH
If gdip_Image Then GdipDisposeImage gdip_Image
If iW <> 0 And iH <> 0 Then
pW = PBox.ScaleWidth
pH = PBox.ScaleHeight
GetImageZoomSize iW, iH, pW, pH
PBox.Cls
If GdipCreateFromHDC(PBox.hDC, gdip_Graphics) = 0 Then
GdipLoadImageFromFile StrPtr(strFileName), gdip_Image
lRet = GdipDrawImageRect(gdip_Graphics, gdip_Image, _
(PBox.ScaleWidth - pW) \ 2, (PBox.ScaleHeight - pH) \ 2, pW, pH) '绘图
If gdip_Image Then GdipDisposeImage gdip_Image

GdipDeleteGraphics gdip_Graphics
End If
End If
GdiplusShutdown gdip_Token
End Sub

Function GetImageZoomSize(ByVal nSrcWidth As Integer, ByVal nSrcHeight As Integer, ByRef nDstWidth As Integer, ByRef nDstHeight As Integer)
        If nSrcWidth / nSrcHeight < nDstWidth / nDstHeight Then
            nDstWidth = nDstHeight * (nSrcWidth / nSrcHeight)
        Else
            nDstHeight = nDstWidth * (nSrcHeight / nSrcWidth)
        End If
    End Function

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

文字版|手机版|小黑屋|VBGood  

GMT+8, 2022-7-1 19:44

VB爱好者乐园(VBGood)
快速回复 返回顶部 返回列表