Hatte am Wochenende die Zeit mich damit zu beschäftigen.
Erstmal danke für die Unterstützung Zardoz.
Habe mir die Links mal angeschaut. Den ersten kannte ich schon. Hat mir bei meiner Anwendung jedoch nicht weiter helfen können.
Der zweite Link war besser und hilfreich.
Die beste Performance habe ich dann mit "GetDiBits" erreicht.
Private Const BI_RGB = 0&
Private Const DIB_RGB_COLORS = 0 ' Farbtabelle in RGB
Private Const videoWidth As Integer = 320
Private Const videoHeight As Integer = 240
Private Const bBytesLength As Long = 230400
Private Type BITMAPINFOHEADER ' 40 Bytes
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 Type
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Dim iBitmap As Long, iDC As Long
Dim videoHandle As Long Dim CapDC As Long
Dim bi24BitInfo As BITMAPINFO
With bi24BitInfo.bmiHeader
.biBitCount = 24
.biCompression = BI_RGB
.biPlanes = 1
.biSize = Len(bi24BitInfo.bmiHeader)
.biWidth = videoWidth
.biHeight = videoHeight
End With
Dim bBytes(1 To 230400) As Byte
CapDC = GetDC(videoHandle)
iDC = CreateCompatibleDC(CapDC)
iBitmap = CreateDIBSection(iDC, bi24BitInfo, DIB_RGB_COLORS, ByVal 0&, ByVal _
0&, ByVal 0&)
SelectObject iDC, iBitmap
BitBlt iDC, 0, 0, bi24BitInfo.bmiHeader.biWidth, _
bi24BitInfo.bmiHeader.biHeight, CapDC, 0, 0, vbSrcCopy
GetDIBits iDC, iBitmap, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), _
bi24BitInfo, DIB_RGB_COLORS
' Die Pixel stehen nun in einem eindimensionalen Array "bBytes" zur Verfügung
SetDIBitsToDevice SnapshotBox.hDC, 0, 0, bi24BitInfo.bmiHeader.biWidth, _
bi24BitInfo.bmiHeader.biHeight, 0, 0, 0, bi24BitInfo.bmiHeader.biHeight, _
bBytes(1), bi24BitInfo, DIB_RGB_COLORS
DeleteDc iDC
DeleteObject iBitmap Dann noch die entsprechenden API-Funktionen einbinden...
Nochmal danke für die Hilfe, sonst wäre ich hier nicht so schnell weiter gekommen.
Grüße
Bastel601
Bild aus Videohandle von Webcam in Array |