hBitmap = LoadImage(App.hInstance, "c:\0.bmp", 0, 0, 0, LR_LOADMAP3DCOLORS)BitBlt(picture1.hdc, DstX, DstY, SrcW, SrcH, hBitmap, 0, 0, vbSrcCopy)以上语句不能实现绘图功能,该如何做才是正确的。

解决方案 »

  1.   

    Private Sub LoadWithLoadImage(ByVal pic As PictureBox, _
        ByVal file_name As String)
    Dim hbm As Long
    Dim wid As Long
    Dim hgt As Long
    Dim temp_dc As Long    ' Load the image using LoadImage.
        wid = pic.ScaleX(pic.ScaleWidth, pic.ScaleMode, _
            vbPixels)
        hgt = pic.ScaleY(pic.ScaleHeight, pic.ScaleMode, _
            vbPixels)
        hbm = LoadImage(ByVal 0&, file_name, _
            IMAGE_BITMAP, wid, hgt, LR_LOADFROMFILE)    ' Make a device context to hold the picture.
        temp_dc = CreateCompatibleDC(0)
        SelectObject temp_dc, hbm    ' Copy the picture into the PictureBox.
        BitBlt pic.hdc, 0, 0, wid, hgt, temp_dc, 0, 0, SRCCOPY    ' Delete the DC and bitmap.
        DeleteDC temp_dc
        DeleteObject hbm    ' Make the image permanent.
        pic.Picture = pic.Image
    End SubPrivate Sub Form_Load()
    Dim file_name As String    file_name = App.Path
        If Right$(file_name, 1) <> "\" Then file_name = _
            file_name & "\"    ' Load using LoadPicture.
        imgUnaliased.Picture = LoadPicture(file_name & _
            "HalfJack2.bmp")    ' Load using LoadWithLoadImage.
        LoadWithLoadImage picAliased, file_name & _
            "HalfJack2.bmp"    ' Copy the picture to an Image control.
        imgCopy.Picture = picAliased.Picture    ' Save the picture into a file.
        SavePicture picAliased.Picture, file_name & _
            "HalfJack2_small.bmp"
    End Sub
     
      
      

  2.   

    参考:
    http://www.vb-helper.com/howto_antialias_with_loadimage_into_file.html
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;187568
      

  3.   

    hBitmap = LoadImage(App.hInstance, SourceFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
    If hBitmap = 0 Then
        Err.Raise vbObjectError + 513, , "装载文件时发生了错误,请检查"
        Exit Sub
    End IfhdcSrc = CreateCompatibleDC(0)'将创建的位图选入屏幕备场景
    SelectObject hdcSrc, hBitmap' Copy the picture into the PictureBox.
    BitBlt pic.hdc, 0, 0, wid, hgt, hdcSrc, 0, 0, SRCCOPY