Webcam capture (VFW)
Posted on 2006-05-08
I've created a remote webcam capture program using VFW (avicap32.dll) in VB6. On most cams and devices, it's able to capture correctly. Now there are some webcams that capture grayscale (non-color) images in my program, although they are able to capture color images (as is tested with other applications).
So here's my main question:
How can I set the capture driver to capture color images using VFW?
I've tried to use the WM_CAP_GET_VIDEOFORMAT and WM_CAP_SET_VIDEOFORMAT messages and changing the BITMAPINFO structure manually, but when changed, WM_CAP_SET_VIDEOFORMAT always returns false, which means the operation wasn't succesfull. I expect the problem to be the size and setting of the bmiColors array. Are there standardized API's for transforming this?
Now I've got secondary question of less importance:
How can I set the capture driver to return JPEG/PNG images instead of DIB/BMP images. I've tried it the same way as setting the color-scale by using WM_CAP_GET_VIDEOFORMAT and WM_CAP_SET_VIDEOFORMAT and changing the 'compression'-flag, but just like setting the color-scale, it always returns false.
One more thing: I don't want to do both things using the pop-up dialogs, everything should be in code.
Maybe these problems are all around memory handling. I prefer a VB solution, but since I couldn't even find a C/C++-solution which would point me in the right direction and I needed some help, even a C++-solution or general info would be very well appreciated.
Thanks in advance!