调用vc组件,将得到的图像rgb数据进行一系列的计算后
将rgb数据返回到vb中,请问 如何将rgb数据以图像的形式显示到picture,thx

解决方案 »

  1.   

    是做avi逐桢分析的
    从avi里拿一个桢出来 做一些处理考虑过存储bmp 不过感觉不是最好吧!
      

  2.   

    用picture1.pset 坐标,rgb(a,b,c)
      

  3.   

    StretchDIBits是你需要的关键API函数。以下是从前写过的一个东西,研究一种自行定义的多帧BMP格式。该组函数绝对可以完成你需要的工作,希望有用。但有些函数是我自己胡思乱想出来的玩意,对你来说可能是画蛇添足的东西,如果看不明白就跳过吧。'[Type Header]Public Type tpBitMapFileHeader '
      bfType(0 To 1) As Byte
      bfSize As Long
      bfReserved1 As Integer
      bfReserved2 As Integer
      bfOffBits As Long
    End TypePublic Type tpBitMapInfoHeader '
      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 TypePublic Type tpBitMapFramesHeader    '多帧格式信息头(仅用于KIB格式)
      bfFramesCount As Long             '帧数
      bfFramesSize As Long              '帧字节容量
      bfFramesTimer As Long             '帧定时器
    End Type'[Type Quad]Public Type tpRGBQuad
      rgbBlue As Byte
      rgbGreen As Byte
      rgbRed As Byte
      rgbReserved As Byte
    End Type'[Type Pixel]Public Type tpPixelRGB24
      rgbBlue As Byte
      rgbGreen As Byte
      rgbRed As Byte
    End TypePublic Type tpPixelRGB32
      rgbBlue As Byte
      rgbGreen As Byte
      rgbRed As Byte
      rgbAlpha As Byte
    End TypePublic Type tpBitMapInfo
      bmiHeader As tpBitMapInfoHeader
      bmiColors As tpRGBQuad
    End Type'[Type BMP FileHeader]Public Type tpBMP_FileHeader_IndexColor16
      bfHeader As tpBitMapFileHeader
      bfInfo As tpBitMapInfoHeader
      bfPalette(0 To 15) As tpRGBQuad
    End TypePublic Type tpBMP_FileHeader_IndexColor256
      bfHeader As tpBitMapFileHeader
      bfInfo As tpBitMapInfoHeader
      bfPalette(0 To 255) As tpRGBQuad
    End TypePublic Type tpBMP_FileHeader_RGB24
      bfHeader As tpBitMapFileHeader
      bfInfo As tpBitMapInfoHeader
    End Type'[Type KIB FileHeader - K.I.B:KiteGirl自定义的多帧BMP格式。]Public Type tpKIB_FileHeader_RGB24
      bfHeader As tpBitMapFileHeader
      bfInfo As tpBitMapInfoHeader
      bfFrames As tpBitMapFramesHeader
    End TypePublic Type tpKIB_FileHeader_AlphaRGB32
      bfHeader As tpBitMapFileHeader
      bfInfo As tpBitMapInfoHeader
      bfFrames As tpBitMapFramesHeader
    End Type'[Type Pack]
    '文件包Public Type tpBMP_FilePack_RGB24     'BMP文件包裹数据结构(RGB 8-8-8 24Bit模式)。
      fpHeader As tpBMP_FileHeader_RGB24    '文件头
      fpPixels() As tpPixelRGB24            '位图数据数组(tpPixelRGB24结构化像素数组)
    End Type'[Type PackWord]
    '工作字Public Type tpBMP_FilePack_RGB24_PackWordRec
      pwName As String
      pwEnabled As Boolean
      pwPack As tpBMP_FilePack_RGB24
    End TypePublic Type tpBMP_FilePack_RGB24_PackWord
      pwCount As Long
      pwPacks() As tpBMP_FilePack_RGB24_PackWordRec
    End TypePublic Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    Public 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 tpBitMapInfo, ByVal wUsage As Long, ByVal dwRop As Long) As LongPublic Const DIB_PAL_COLORS = 1Public Const DIB_RGB_COLORS = 0Public Const SRCCOPY = &HCC0020Public pubPackWord_RGB24 As tpBMP_FilePack_RGB24_PackWord'[BMP_FilePack_RGB24_PackWord]Public Function BMP_FilePack_RGB24_PackWord_ListToComboBox(ByRef pComboBox As ComboBox)
      Dim tIndex As Long
      
      If CBool(pubPackWord_RGB24.pwCount) Then
        pComboBox.Clear
        pComboBox.AddItem "None", 0
        For tIndex = 1 To UBound(pubPackWord_RGB24.pwPacks)
          pComboBox.AddItem pubPackWord_RGB24.pwPacks(tIndex).pwName, tIndex
        Next
        pComboBox.ListIndex = 0
      End If
    End FunctionPublic Function BMP_FilePack_RGB24_PackWord_ViewToForm(ByRef pForm As Form, ByVal pNumber As Long, Optional ByVal pLeft As Long = 0, Optional ByVal pTop As Long = 0, Optional ByVal pViewMode As Integer = 0) As Long
      Dim tOutLong As Long
      Dim tPack As tpBMP_FilePack_RGB24
      
      With pubPackWord_RGB24.pwPacks(pNumber)
        If .pwEnabled Then
          tPack = .pwPack
          tOutLong = BMP_FilePack_RGB24_ShowToForm(pForm, tPack, pLeft, pTop, pViewMode)
        End If
      End With
      
      BMP_FilePack_RGB24_PackWord_ViewToForm = tOutLong
    End FunctionPublic Function BMP_FilePack_RGB24_PackWord_Del(ByVal pIndex As Long) As Boolean
      Dim tOutBool As Boolean
      
      tOutBool = False
      
      With pubPackWord_RGB24
        
        If .pwCount And pIndex < .pwCount Then
          .pwPacks(pIndex).pwEnabled = False
        End If
        
      End With
      
      BMP_FilePack_RGB24_PackWord_Del = tOutBool
    End Function
      

  4.   

    Public Function BMP_FilePack_RGB24_PackWord_AddByFile(ByVal pFileName As String, Optional ByVal pName As String, Optional ByVal pIndex As Long = 0)
      Dim tOutLong As Long
      Dim tName As String
      Dim tPack As tpBMP_FilePack_RGB24
      
      If pName = "" Then
          tName = pFileName
        Else
          tName = pName
      End If
      
      tPack = BMP_FilePack_RGB24_GetByFile(pFileName)
      
      tOutLong = BMP_FilePack_RGB24_PackWord_Add(tPack, tName, pIndex)
      
      BMP_FilePack_RGB24_PackWord_AddByFile = tOutLong
    End FunctionPublic Function BMP_FilePack_RGB24_PackWord_Add(ByRef pPack As tpBMP_FilePack_RGB24, Optional ByVal pName As String, Optional ByVal pIndex As Long = 0) As Long
      'BMP_FilePack_RGB24_PackWord_Add函数
      '语法:[tOutLong]=BMP_FilePack_RGB24_PackWord_Add(pPack)
      '说明:将一个tpBMP_FilePack_RGB24包裹结构的有效位图交给系统“寄存堆”。并返回一个索引号。
      '参数:tpBMP_FilePack_RGB24   pPack       准备存储给寄存堆的tpBMP_FilePack_RGB24包裹变量。
      '返回:long                   tOutLong    该包裹在寄存堆里的标号。
      
      Dim tOutLong As Long
      
      '! - 自动分配一个空的记录标号。
      If Not CBool(pIndex) Then
          tOutLong = BMP_FilePack_RGB24_PackWord_GetSpace
        Else
          tOutLong = pIndex
      End If
      
      '! - 存储数据到标号指明的数组元素。
      
      With pubPackWord_RGB24
        If pIndex < .pwCount Then
          .pwPacks(tOutLong).pwName = pName
          .pwPacks(tOutLong).pwPack = pPack
          .pwPacks(tOutLong).pwEnabled = True
        End If
      End With
      
      BMP_FilePack_RGB24_PackWord_Add = tOutLong
    End FunctionPublic Function BMP_FilePack_RGB24_PackWord_GetSpace() As Long
      'BMP_FilePack_RGB24_PackWord_GetSpace函数
      '说明:在系统“寄存堆”里寻找空位,如果没有就创建一个。返回一个有效的寄存堆索引号。
      
      Dim tOutLong As Long
      
      With pubPackWord_RGB24
        If Not CBool(.pwCount) Then
            
            '! - 如果寄存堆是空的。初始化寄存堆数组。
            ReDim .pwPacks(1)
            .pwCount = UBound(.pwPacks) + 1
            tOutLong = 1
          
          Else
            
            '! - 查找寄存堆里的空记录。
            Dim tIndex As Long
            For tIndex = 1 To UBound(.pwPacks)
              If Not .pwPacks(tIndex).pwEnabled Then
                tOutLong = tIndex
                Exit For
              End If
            Next
          
            '! - 如果没有空记录则为数组增加一个元素,并返回最后一个元素。
            If Not CBool(tOutLong) Then
              ReDim Preserve .pwPacks(.pwCount)
              tOutLong = .pwCount
              .pwCount = UBound(.pwPacks) + 1
            End If
           
        End If
            
      End With
      
      BMP_FilePack_RGB24_PackWord_GetSpace = tOutLong
    End Function'[BMP_FilePack_RGB24 Pack]Public Function BMP_FilePack_RGB24_GetByPackNumber(ByVal pNumber As Long) As tpBMP_FilePack_RGB24End FunctionPublic Function BMP_FilePack_RGB24_ShowToForm(ByVal pForm As Form, ByRef pPack As tpBMP_FilePack_RGB24, Optional ByVal pLeft As Long = 0, Optional ByVal pTop As Long = 0, Optional ByVal pViewMode As Integer = 0) As Long
      'BMP_FilePack_RGB24_ShowToForm函数
      '说明:将一个tpBMP_FilePack_RGB24包裹结构的有效位图交给指明的窗体显示。
      Dim tOutLong As Long
      
      Dim tBitMapInfo As tpBitMapInfo
      
      Dim tSurWidth As Long
      Dim tSurHeight As Long
      Dim tDesWidth As Long
      Dim tDesHeight As Long
      Dim tPixel() As tpPixelRGB24
      Dim tViewMode As Integer
      Dim tViewCls As Integer
      
      With tBitMapInfo
        .bmiHeader = pPack.fpHeader.bfInfo
        tSurWidth = .bmiHeader.biWidth
        tSurHeight = .bmiHeader.biHeight
      End With
      
      tDesWidth = pForm.ScaleWidth
      tDesHeight = pForm.ScaleHeight
      
      '! - pViewMode
      
      tViewMode = pViewMode Mod 256
      tViewCls = pViewMode \ 256
      
      If tViewMode = 1 Then
          tDesWidth = tSurWidth
          tDesHeight = tSurHeight
        ElseIf tViewMode = 2 Then
          tDesWidth = (tDesHeight * tSurWidth) \ tSurHeight
        ElseIf tViewMode = 3 Then
          tDesHeight = (tDesWidth * tSurHeight) \ tSurWidth
        ElseIf tViewMode = 4 Then
          Dim tSurScale As Double
          Dim tDesScale As Double
          tSurScale = tSurHeight / tSurWidth
          tDesScale = tDesHeight / tDesWidth
          If tDesScale > tSurScale Then
              tDesHeight = (tDesWidth * tSurHeight) \ tSurWidth
            Else
              tDesWidth = (tDesHeight * tSurWidth) \ tSurHeight
          End If
      End If
      
      tPixel() = pPack.fpPixels()
      
      With pForm
        .AutoRedraw = True
        If CBool(tViewCls) Then .Cls
        tOutLong = StretchDIBits(.hDC, pLeft, pTop, tDesWidth, tDesHeight, 0, 0, tSurWidth, tSurHeight, tPixel(0), tBitMapInfo, DIB_RGB_COLORS, SRCCOPY)
        .AutoRedraw = False
        .Cls
      End With
      
      BMP_FilePack_RGB24_ShowToDC = tOutLong
    End FunctionPublic Function BMP_FilePack_RGB24_GetByFile(ByVal pFileName As String) As tpBMP_FilePack_RGB24
      'BMP_FilePack_RGB24_GetByFile函数。
      '语法:[tOutPack]=BMP_FilePack_RGB24_GetByFile(pFileName)
      '说明:从指定的位图文件获得一个tpBMP_FilePack_RGB24包裹结构。
      '参数:String                 pFileName   文件名
      '返回:tpBMP_FilePack_RGB24   tOutPack    返回的tpBMP_FilePack_RGB24包裹结构。
      '说明:·文件必须是有效且格式正确的BMP文件,否则可能导致程序返回错误结果甚至出错。
      
      Dim tOutPack As tpBMP_FilePack_RGB24
      
      Dim tFileNumber As Integer
      Dim tPixelsSize As Long
      Dim tPixel As tpPixelRGB24
      Dim tSeekAddress As Long
      Dim tFileSize As Long
      
      '! - FileOpen
      tFileNumber = AnyFile_OpenGetNumber_ForBinary(pFileName)
      
      tFileSize = LOF(tFileNumber)
      
      Get #tFileNumber, 1, tOutPack.fpHeader
        
      With tOutPack.fpHeader.bfHeader
        tPixelsSize = (((.bfSize - .bfOffBits) + 1) \ 3) - 1
        tSeekAddress = .bfOffBits + 1
      End With
      
      ReDim tOutPack.fpPixels(0 To tPixelsSize)  Get #tFileNumber, tSeekAddress, tOutPack.fpPixels
          
      '! - FileClose
      Close #tFileNumber
      
      BMP_FilePack_RGB24_GetByFile = tOutPackEnd Function'[PackPtr]Function PtrGetByPack_RGB24(ByRef pPack As tpBMP_FilePack_RGB24) As Long
      Dim tOutPtr As Long
      Dim tPack As tpBMP_FilePack_RGB24
      tPack = pPack
      tOutPtr = VarPtr(tPack)
      PtrGetByPack_RGB24 = tOutPtr
    End Function'[Other]Public Function AnyFile_OpenGetNumber_ForBinary(ByVal pFileName As String) As Integer
      Dim tOutInt As Integer
      
      tOutInt = FreeFile
      Open pFileName For Binary As #tOutInt
      
      AnyFile_OpenGetNumber_ForBinary = tOutInt
    End Function
      

  5.   

    由于是许多组RGB数据,然后通过Rgb(R,G,B)函数转化为一组颜色值,即可通过该组颜色在PictureBox上画一组点,这些点所组成的图案就是你所要求的图像哦