capSetVideoFormat

Creator

Member
Joined
Aug 14, 2003
Messages
20
capSetVideoFormat - *** Urgent Help ***

Hi, I got a piece of code below it supposes to set the video format of a webcam....but it does not works....

can someone help me out here, Ive been trying to get it working for a few days. It running with no error, but just not setting the format right.

Thk


----------------------Code----------------------------------
API declaration
Declare Function SendMessageFormat Lib "USER32" Alias "SendMessageA" ( _
ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
ByRef lParam As Object) As Integer


Const WM_CAP_SET_VIDEOFORMAT As Integer = (WM_CAP_START + 45)


Private Structure RGBQUAD
Dim rgbBlue As Byte
Dim rgbGreen As Byte
Dim rgbRed As Byte
Dim rgbReserved As Byte
End Structure

Private Structure BITMAPINFOHEADER 40 bytes
Dim biSize As Long
Dim biWidth As Long
Dim biHeight As Long
Dim biPlanes As Integer
Dim biBitCount As Integer
Dim biCompression As Long
Dim biSizeImage As Long
Dim biXPelsPerMeter As Long
Dim biYPelsPerMeter As Long
Dim biClrUsed As Long
Dim biClrImportant As Long
End Structure

Private Structure BITMAPINFO
Dim bmiHeader As BITMAPINFOHEADER
Dim bmiColors As RGBQUAD
End Structure



Private Sub capSetFormat()

Dim bmi As BITMAPINFO
Dim wSize As Byte structure size
Dim test As Boolean

With bmi.bmiHeader
.biSize = 40
.biPlanes = 1
.biBitCount = 24
.biCompression = 0
.biClrUsed = 0
.biClrImportant = 0
.biSizeImage = (640 * 480) * 3
.biWidth = 640
.biHeight = 480
End With

SendMessageFormat(hWnd, WM_CAP_SET_VIDEOFORMAT, 40, bmi)

End Sub

------------------End code---------------------------------
 
Youll need to replace the Longs in the Structure definition with Integers, and the Integers with Shorts. The sizes of the data-types have shifted in .NET to comply with those in C++.
 
Back
Top