位图信息为vc中读进来的,vc中定义为:#ifndef _BLTMAPSRUCT
#DEFINE _BLTMAPSRUCT
typedef struct _Bitmapdf
{
   byte* pBuffer;
   long  bitSize;
   DWORD lHeight;
   WORD  bbitCount;
   WORD  bPlane;
}BITMAPSRUCT,* LPBITMAPSRUCT;
#endif
HRESULT WINAPI InitMineOut(void);
HRESULT WINAPI DESTROYOOUT(void);
HRESULT WINAPI GetGraphicOut(LPBITMAPDATA pMap);
vb中定义为:
Public Type Bitmapdf
  pBuffer As Long
  bitSize As Long
  lWidth As Long
  lHeight As Long
  bbitCount As Integer
  bPlane As Integer
End TypePublic Declare Function GetGraphicOut Lib "outgraph.dll" (pMap As Bitmapdf) As Long
其中,pbuffer为缓存中的位图信息,bitsize为pbuffer大小,lwidth=640和lheigh=480为位图高和宽,bbitcount=24为色深,bplane=1如何利用这个信息,在vb中的picturebox中显示这个图形?

解决方案 »

  1.   

    该用什么API函数,怎么用,知道的告诉我好不!!!
      

  2.   

    直接利用API在VB中画就完了,用VC干什么啊!
      

  3.   

    位图数据是利用vc做的dll读进来的,怎么把这读进来的位图信息转化为图象,楼上说的利用API,是利用什么API?
      

  4.   

    给你举个例子
    '----------- 模块 -----------
    Public Declare Function CreateBitmapIndirect Lib "gdi32" (lpBitmap As BITMAP) As Long
    Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As LongPublic Type BITMAP '14 bytes
            bmType As Long
            bmWidth As Long
            bmHeight As Long
            bmWidthBytes As Long
            bmPlanes As Integer
            bmBitsPixel As Integer
            bmBits As Long
    End TypePublic Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
    Public Declare Function GetGraphicOut Lib "outgraph.dll" (pMap As Bitmapdf) As LongPublic Type Bitmapdf
      pBuffer As Long
      bitSize As Long
      lWidth As Long
      lHeight As Long
      bbitCount As Integer
      bPlane As Integer
    End TypePublic Function CreateBMP(tBMPDef As Bitmapdf) As Long
        Dim bi As BITMAP
        With bi
            .bmPlanes = tBMPDef.bPlane
            .bmBitsPixel = tBMPDef.bbitCount
            .bmHeight = tBMPDef.lHeight
            .bmWidth = tBMPDef.lWidth
            .bmType = 0
            .bmWidthBytes = GetWidthBytes(.bmBitsPixel, .bmWidth)
            .bmBits = tBMPDef.pBuffer
        End With
        CreateBMP = CreateBitmapIndirect(bi)
    End FunctionPublic Function DrawBMP(ByVal hDestDC As Long) As Boolean
        Dim tMap As Bitmapdf
        Dim hTmpDC As Long
        Dim hBmp As Long
        
        GetGraphicOut tMap
        
        hTmpDC = CreateCompatibleDC(hDestDC)
        
        hBmp = CreateBMP(tMap)
        
        SelectObject hTmpDC, hBmp
        
        BitBlt hDestDC, 0, 0, tMap.lWidth, tMap.lHeight, hTmpDC, 0, 0, SRCCOPY
        
        DeleteObject hBmp
        
        DeleteObject lTmpDC
    End FunctionPrivate Function GetWidthBytes(ByVal bbitCount As Integer, ByVal lBMPWidth As Long) As Long
        Dim i As Single
        Select Case bbitCount
        Case 1, 4, 8, 16, 24, 32
        Case Else
            bbitCount = 1
        End Select
        i = lBMPWidth * bbitCount / 8
        GetWidthBytes = IIf(i = Int(i), i, Int(i) + 1)
        GetWidthBytes = GetWidthBytes Mod 2 + GetWidthBytes
    End Function
    '----------- 窗体 -----------
    Private Sub Form_Load()
        DrawBMP Picture1.hdc
    End Sub
      

  5.   

    Public Type Bitmapdf
      pBuffer As Long
      bitSize As Long
      lWidth As Long
      lHeight As Long
      bbitCount As Integer
      bPlane As Integer
    End TypeType rgbquad
    rgbBlue As Byte
    rgbGreen As Byte
    rgbRed As Byte
    rgbReserved As Byte
    End TypeType BITMAPINFOHEADER
    biSize As Long
    biWidth As Long
    biHeight As Long
    biPlanes As Integer
    biBitCount As Integer
    biCompression As Long
    biSizeImage As Long
    biXPelsPerMeter As Long
    biYPelsPerMeter As Long
    biClrUsed As Long
    biClrImportant As Long
    End TypeType BITMAPINFO
    bmiHeader As BITMAPINFOHEADER
    bmiColors(0 To 255) As rgbquad
    End TypePublic Declare Function StretchDIBits Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal dX As Long, ByVal dY As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal wSrcWidth As Long, ByVal wSrcHeight As Long, lpBits As Any, lpBitsInfo As BITMAPINFO, ByVal wUsage As Long, ByVal dwRop As Long) As LongPublic Declare Function SelectObject Lib "gdi32.dll" (ByVal hDC As Long, ByVal hObject As Long) As Long
    Public Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hDC As Long) As Long
    Public Declare Function GetObject Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As LongType BITMAP
        bmType As Long
        bmWidth As Long
        bmHeight As Long
        bmWidthBytes As Long
        bmPlanes As Integer
        bmBitsPixel As Integer
        bmBits As Long
    End Type    Dim Bitif As BITMAPINFO
        Dim tout As BitmapdfPrivate Sub Command5_Click()
        On Error GoTo err
        Dim ret, retbit As Long   
        ret = GetGraphicOut(tout)
        ReDim b(tout.bitSize)
        CopyMemory b(0), ByVal tout.pBuffer, tout.bitSize
        With Bitif.bmiHeader
            .biBitCount = tout.bbitCount
            .biWidth = tout.lWidth
            .biHeight = tout.lHeight
            .biPlanes = tout.bPlane
            .biSize = 40
        End With
        
        Dim P As Object
        Set P = Picture2.Container
        
        Dim OldSM As Long
        Dim OldB As Long
        
        If Not P Is Nothing Then
            OldSM = P.ScaleMode
            P.ScaleMode = vbPixels
        End If
        OldB = Picture2.BorderStyle
        Picture2.BorderStyle = 0
        Picture2.AutoRedraw = True
        Picture2.Move Picture2.Left, Picture2.Top, tout.lWidth, tout.lHeight
        Call StretchDIBits(Picture2.hDC, 0, 0, Picture2.Width, Picture2.Height, 0, 0, tout.lWidth, tout.lHeight, b(0), Bitif, 0, ByVal vbSrcCopy)
        Picture2.BorderStyle = OldB
        If Not P Is Nothing Then
            P.ScaleMode = OldSM
        End If
        
       
    err:
         
    End Sub
      

  6.   

    和我的问题类似:将图像rgb数据显示到picture
    http://expert.csdn.net/Expert/topic/2939/2939984.xml?temp=5.115908E-02