Chriss,
This is what worked (code in the Init of the Form). Note that I created a oWebCam custom class as wrapper class to the Github code.
[pre]LOCAL loBitMapInfoHeader, lcString, lpString
IF ThisForm.oWebcam.InitCaptureWindow( This.HWnd, This.shpWebcam.Left, This.shpWebcam.Top )
IF ThisForm.oWebcam.capHeight # ThisForm.shpWebcam.Height OR ThisForm.oWebcam.capWidth # ThisForm.shpWebcam.Width
IF ThisForm.oWebcam.UseBitMapInfo
#DEFINE WM_CAP_START 0x0400
#DEFINE WM_CAP_SET_VIDEOFORMAT ( WM_CAP_START + 45 )
loBitMapInfoHeader = NEWOBJECT( "BitMapInfoHeader" )
loBitMapInfoHeader.biSize = 40
loBitMapInfoHeader.biWidth = 640
loBitMapInfoHeader.biHeight = 480
loBitMapInfoHeader.biPlanes = 1
loBitMapInfoHeader.biBitCount = 16
loBitMapInfoHeader.biCompression = 844715353
loBitMapInfoHeader.biSizeImage = 614400
loBitMapInfoHeader.biXPelsPerMeter = 0
loBitMapInfoHeader.biYPelsPerMeter = 0
loBitMapInfoHeader.biClrUsed = 0
loBitMapInfoHeader.biClrImportant = 0
lpString = loBitMapInfoHeader.GetPointer( 40 )
ThisForm.oWebcam.MessageCenter( WM_CAP_SET_VIDEOFORMAT, 40, lpString )
ELSE
ThisForm.oWebcam.ShowFormatDialog()
ENDIF
ENDIF
ThisForm.oWebcam.StartPreview()
ELSE
* MESSAGEBOX( "Webcam connection unsuccessful.", 0+16, ThisForm.Caption )
ENDIF
ThisForm.RefreshControls()
[/pre]
Here is what did not work:
I simply delegated (and rightfully so) the function of SetVideoFormat to the Webcam class as method SetVideoFormat(). So, in the Init() of the Form, the code would simply be:
[pre]IF ThisForm.oWebcam.InitCaptureWindow( This.HWnd, This.shpWebcam.Left, This.shpWebcam.Top )
IF ThisForm.oWebcam.capHeight # ThisForm.shpWebcam.Height OR ThisForm.oWebcam.capWidth # ThisForm.shpWebcam.Width
ThisForm.oWebcam.SetVideoFormat() && -> the code in above is now here
ENDIF
ThisForm.oWebcam.StartPreview()
ELSE
* MESSAGEBOX( "Webcam connection unsuccessful.", 0+16, ThisForm.Caption )
ENDIF
ThisForm.RefreshControls()
[/pre]
Here is the code Webcam.SetVideoFormat():
[pre]LOCAL loBitMapInfoHeader, lcString, lpString
IF This.UseBitMapInfo
loBitMapInfoHeader = NEWOBJECT( This.BitMapInfoHeaderClass, This.BitMapHeaderClassLib )
loBitMapInfoHeader.biSize = loBitMapInfoHeader.SizeOf()
loBitMapInfoHeader.biWidth = This.biWidth
loBitMapInfoHeader.biHeight = This.biHeight
loBitMapInfoHeader.biPlanes = This.biPlanes
loBitMapInfoHeader.biBitCount = This.biBitCount
loBitMapInfoHeader.biCompression = This.biCompression
loBitMapInfoHeader.biSizeImage = This.biSizeImage
loBitMapInfoHeader.biXPelsPerMeter = This.biXPelsPerMeter
loBitMapInfoHeader.biYPelsPerMeter = This.biYPelsPerMeter
loBitMapInfoHeader.biClrUsed = This.biClrUsed
loBitMapInfoHeader.biClrImportant = This.biClrImportant
lpString = loBitMapInfoHeader.GetPointer( loBitMapInfoHeader.SizeOf() )
This.MessageCenter( WM_CAP_SET_VIDEOFORMAT, loBitMapInfoHeader.SizeOf(), lpString )
ELSE
This.ShowFormatDialog()
ENDIF[/pre]
Take note that biHeight, biWidth, biPlane etc... are now properties of class Webcam.