It shows that ther must be an Error in the code.
Code: Select all
; important: configure your web cam : 320*240*rgb24
#WM_CAP_START = #WM_USER
#WM_CAP_SET_CALLBACK_FRAME = #WM_CAP_START + 5
#WM_CAP_DRIVER_CONNECT = #WM_CAP_START + 10
#WM_CAP_SET_OVERLAY = #WM_CAP_START + 51
#WM_CAP_SET_PREVIEW = #WM_CAP_START + 50
#WM_CAP_SET_PREVIEWRATE = #WM_CAP_START + 52
#WM_CAP_SET_SCALE = #WM_CAP_START + 53
Structure VIDEOHDR
lpData.l
dwBufferLength.l
dwBytesUsed.l
dwTimeCaptured.l
dwUser.l
dwFlags.l
dwReserved.l[4]
EndStructure
Procedure capFrameCallback(hWnd.l, *lpVHdr.VIDEOHDR)
If hWnd
hBmp = UseImage( 1 )
w = ImageWidth()
h = ImageHeight()
bmi.BITMAPINFO
bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
bmi\bmiHeader\biWidth = w
bmi\bmiHeader\biHeight = h
bmi\bmiHeader\biPlanes = 1
bmi\bmiHeader\biBitCount = 32
bmi\bmiHeader\biCompression = #BI_RGB
hdc = StartDrawing(ImageOutput())
If hdc
SetDIBits_( hdc, hBmp, 0, h, *lpVHdr\lpData, bmi, #DIB_RGB_COLORS)
StopDrawing()
EndIf
If StartDrawing(WindowOutput())
DrawImage(UseImage(1),0 , 250)
StopDrawing()
EndIf
EndIf
EndProcedure
OpenWindow(0,0,0,325,495,#PB_Window_SystemMenu|#PB_Window_WindowCentered,"cam")
If OpenLibrary(0,"avicap32.dll")
hWndC = CallFunctionFast(IsFunction(0,"capCreateCaptureWindowA"),"cap",#WS_CHILD|#WS_VISIBLE,0,0,320,240,WindowID(),1)
;hWndC = CallFunctionFast(IsFunction(0,"capCreateCaptureWindowA"),"cap",#WS_CHILD,0,0,320,240,WindowID(),1)
EndIf
CreateImage(1, 320, 240)
SendMessage_(hWndC, #WM_CAP_DRIVER_CONNECT, 0, 0)
SendMessage_(hWndC, #WM_CAP_SET_SCALE, #True, 0)
SendMessage_(hWndC, #WM_CAP_SET_OVERLAY, #True, 0)
SendMessage_(hWndC, #WM_CAP_SET_PREVIEW, #True, 0)
SendMessage_(hWndC, #WM_CAP_SET_PREVIEWRATE, 60, 0)
SendMessage_(hWndC, #WM_CAP_SET_CALLBACK_FRAME, 0, @capFrameCallback())
ActivateWindow()
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
SendMessage_(hWndC, #WM_CAP_SET_CALLBACK_FRAME, 0, 0)
Break
EndSelect
ForEver
End