00001
00002
00004
00005 #if !defined VFWIMAGEPROCESSOR_H
00006 #define VFWIMAGEPROCESSOR_H
00007
00008 #include <windows.h>
00009 #include <vfw.h>
00010 #include <string.h>
00011
00012 #define MAX_VFW_DEVICES 10
00013 #define ERROR_SIZE 100
00014 class CVFWCapture
00015 {
00016 public:
00017 CVFWCapture();
00018 virtual ~CVFWCapture();
00019 CVFWCapture(const CVFWCapture &CopyFrom);
00020 CVFWCapture &operator =(const CVFWCapture &CopyFrom);
00021
00022 BOOL Initialize(SHORT DriverIndex = 0);
00023 VOID Destroy();
00024
00025 BOOL SetDriver(SHORT DriverIndex);
00026
00027 HWND GetCapWindow();
00028
00029 BOOL CaptureDIB(PBITMAPINFO *Bitmap, ULONG BitmapLength, ULONG *RetBitmapLength);
00030 BOOL EnablePreviewVideo(HWND Parent, INT x, INT y, INT PreviewRate = 30);
00031 BOOL EnablePreviewVideo(HWND Parent, INT x, INT y, INT Width, INT Height, INT PreviewRate = 30);
00032 BOOL DisablePreviewVideo();
00033 BOOL DriverGetCaps(CAPDRIVERCAPS *Caps);
00034 VOID CancelCapture();
00035 BOOL AllocDIBImage(PBITMAPINFO *ppImageData, ULONG *AllocatedSize);
00036
00037 BITMAPINFOHEADER GetBitmapInfoHeader();
00038
00039 VOID GetPreviousError(INT *ErrorID, char *ErrorString, BOOL ResetError = FALSE);
00040
00041 static ULONG CalcBitmapSize(const BITMAPINFOHEADER &bmiHeader);
00042 static ULONG CalcBitmapInfoSize(const BITMAPINFOHEADER &bmiHeader);
00043
00044 friend LRESULT CALLBACK ErrorCallbackProc(HWND hWnd, int nErrID, LPSTR lpErrorText);
00045 friend LRESULT CALLBACK StatusCallbackProc(HWND hWnd, int nID, LPCSTR lpsz);
00046 friend LRESULT CALLBACK FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);
00047
00048 private:
00049 HWND m_hWndVideo;
00050 BITMAPINFOHEADER m_BitmapInfoHeader;
00051 PBITMAPINFO m_TransferBitmapInfo;
00052 ULONG m_TransferBitmapInfoSize;
00053 INT m_DriverIndex;
00054 INT m_ErrorID;
00055 char m_ErrorText[ERROR_SIZE];
00056
00057
00058 static UINT m_ValidDriverIndex[MAX_VFW_DEVICES];
00059 static USHORT m_TotalVideoDrivers;
00060
00061 private:
00062 CVFWCapture &Copy(const CVFWCapture &CopyFrom);
00063 };
00064
00065 #endif // !defined VFWIMAGEPROCESSOR_H