[英]Convert a Picture Box image pixels to a Byte Array in VB6
我有一個VB6圖片框,可以從視頻捕獲設備獲取圖像。
我試圖弄清楚如何將圖片框轉換為字節數組。
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Sub GetPictureBytes()
Dim PicBits() As Byte, PicInfo As BITMAP
GetObject Picture1.Picture, Len(PicInfo), PicInfo
ReDim PicBits((PicInfo.bmWidth * PicInfo.bmHeight * 3) - 1) As Byte
GetBitmapBits Picture1.Picture, UBound(PicBits), PicBits(0)
End Sub
自從我使用VB6以來已經很長時間了,但據我記憶,您可以將圖像序列化為PropertyBag
並將內容作為字節數組獲取。
我所知道的唯一選擇是需要大量使用WinAPI來實現同樣的目標。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.