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