如题!

解决方案 »

  1.   

    loadpicture函数吧!也不行!还有其他办法吗?
      

  2.   

    vb不能直接加载png格式图片,解决办法多种:
    1. 用第3方控件,下载
    2. 用编辑软件将png格式图片另存为jpg
     
      

  3.   

    建议考虑使用GDI+函数来处理,Win2k系统以上现成的函数支持。
    速度快,使用也简单。
      

  4.   

    Private Enum GpStatus
        Ok = 0
        GenericError = 1
        InvalidParameter = 2
        OutOfMemory = 3
        ObjectBusy = 4
        InsufficientBuffer = 5
        NotImplemented = 6
        Win32Error = 7
        WrongState = 8
        Aborted = 9
        FileNotFound = 10
        ValueOverflow = 11
        AccessDenied = 12
        UnknownImageFormat = 13
        FontFamilyNotFound = 14
        FontStyleNotFound = 15
        NotTrueTypeFont = 16
        UnsupportedGdiplusVersion = 17
        GdiplusNotInitialized = 18
        PropertyNotFound = 19
        PropertyNotSupported = 20
    End Enum
    Private Type GdiplusStartupInput
        GdiplusVersion As Long
        DebugEventCallback As Long
        SuppressBackgroundThread As Long
        SuppressExternalCodecs As Long
    End TypePrivate Declare Function GdiplusStartup Lib "gdiplus" (token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As GpStatus
    Private Declare Sub GdiplusShutdown Lib "gdiplus" (ByVal token As Long)Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hdc As Long, graphics As Long) As GpStatus
    Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal filename As String, image As Long) As GpStatusPrivate Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As GpStatus
    Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal image As Long) As GpStatus
    Private Declare Function GdipCreateBitmapFromFile Lib "gdiplus" (ByVal filename As Long, bitmap As Long) As GpStatusPrivate Declare Function GdipCreateCachedBitmap Lib "gdiplus" (ByVal bitmap As Long, ByVal graphics As Long, cachedBitmap As Long) As GpStatus
    Private Declare Function GdipDrawCachedBitmap Lib "gdiplus" (ByVal graphics As Long, ByVal cachedBitmap As Long, ByVal x As Long, ByVal y As Long) As GpStatus
    Private Declare Function GdipDeleteCachedBitmap Lib "gdiplus" (ByVal cachedBitmap As Long) As GpStatusDim token As LongPrivate Sub Form_Load()
        Dim GpInput As GdiplusStartupInput
        Dim graphics As Long, lhdc As Long
        Dim lngImage As Long, stat As GpStatus
        Dim lngCached As Long, filename As String
        Dim i As Integer, startTime As Single
        Dim finalTime As Single    'Set your fileName in here.
        filename = App.Path & "\a.png"
       ' MsgBox filename
        GpInput.GdiplusVersion = 1
        If GdiplusStartup(token, GpInput) <> Ok Then
            MsgBox "Error loading GDI+", vbCritical
            Unload Me
        End If
        Me.AutoRedraw = True
        Picture1.AutoRedraw = True
         Picture1.Left = -Picture1.Width
        'Initialize the graphics class
        If GdipCreateFromHDC(Picture1.hdc, graphics) = Ok Then
            startTime = 1
            
            If GdipLoadImageFromFile(StrConv(filename, vbUnicode), lngImage) = Ok Then
                For i = 0 To 1 ' 1000
                    stat = GdipCreateCachedBitmap(lngImage, graphics, lngCached)
                   
                    stat = GdipDrawCachedBitmap(graphics, lngCached, Me.ScaleLeft, Me.ScaleTop)
                    stat = GdipDeleteCachedBitmap(lngCached)            Next
            End If
            finalTime = i - 1
            Me.Caption = finalTime        GdipDisposeImage lngImage
            GdipDeleteGraphics graphics
        Else
            Unload Me
        End If
       Set Image1.Picture = Picture1.image
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        GdiplusShutdown (token)
    End Sub
      

  5.   

    在窗体上放一Picture1,Image1,同一目录下放一PNG格式图片,这里是a.png ,注意文件目录不能太深.最 好在根目录下.