VBGood网站全文搜索 Google



查看: 1559|回复: 0


发表于 2015-8-24 10:37:22 | 显示全部楼层 |阅读模式
用此菜单这能保存png图片 不能保存图片上面的控件,如何才能把上面的控件也能保存下来


Public Function SaveToFile_PNG(ByVal FileName As String, Optional ByVal PromptOverwrite As Boolean = True) As Boolean

    ' Requires GDI+ and/or zLib installed on the system, otherwise function fails
    ' TEST isGDIplusEnabled or isZlibEnabled
    ' To use the optional PNG properties, isZlibEnabled must be True
    '   See PngPropertySet and PngPropertyGet
    ' Function saves the 32bpp image to file, converting it to a PNG format first
    ' FileName :: full path & name of file to be created
    ' PromptOverwrite :: if True, the user will be offered an option to abort
    '    if the target file already exists
    ' Per PNG recommendations, the PNG is converted with non-premultiplied pixels
    If FileName = vbNullString Then Exit Function
    If m_Handle = 0& Then Exit Function
    If iparseFileExists(FileName, ((m_osCAP And osIsNT) = osIsNT)) Then
        If PromptOverwrite = True Then
            If MsgBox("Overwrite existing file?", vbYesNo + vbDefaultButton2 + vbQuestion, "Overwrite Confirmation") = vbNo Then
                Exit Function
            End If
        End If
        If iparseDeleteFile(FileName, ((m_osCAP And osIsNT) = osIsNT)) = False Then Exit Function
    End If
    Dim aDummy() As Byte
    Dim cGDIp As cGDIPlus, cZlib As cPNGwriter
    Dim bSuccess As Boolean
    If m_PNGprops Is Nothing Then   ' no special PNG properties set, use GDI+
        If m_GDIplus Is Nothing Then
            Set cGDIp = New cGDIPlus
            Set cGDIp = m_GDIplus
        End If
        If cGDIp.SaveToPNG(FileName, aDummy(), Me, m_GDItoken) = False Then
            Set cZlib = New cPNGwriter  ' failed, attempt to use zLIB
            bSuccess = cZlib.SavePNGex(Me, FileName, aDummy())
            bSuccess = True         ' GDI+ created the PNG
        End If
        ' user set some optional PNG properties (See PngPropertySet), use zLib
        If m_PNGprops.SavePNGex(Me, FileName, aDummy()) = False Then
            If m_GDIplus Is Nothing Then
                Set cGDIp = New cGDIPlus    ' failed, attempt to use GDI+
                Set cGDIp = m_GDIplus
            End If
            bSuccess = cGDIp.SaveToPNG(FileName, aDummy(), Me, m_GDItoken)
            bSuccess = True         ' zLIB created the PNG
        End If
    End If
    SaveToFile_PNG = bSuccess
End Function


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

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



GMT+8, 2022-7-5 12:10

快速回复 返回顶部 返回列表