61 #define BI_I420 0x30323449 62 #define BI_YUY2 0x32595559 77 #define myClip(x) (((x) > 255) ? 255 : ((x) < 0) ? 0 : (unsigned char) (x)) 78 static inline void yuv2rgb(
unsigned char y,
unsigned char u,
unsigned char v,
unsigned char *out)
81 int D = (int) u - 128;
82 int E = (int) v - 128;
84 int R = (( 298 * C + 409 * E + 128) >> 8);
85 int G = (( 298 * C - 100 * D - 208 * E + 128) >> 8);
86 int B = (( 298 * C + 516 * D + 128) >> 8);
101 return (LRESULT) TRUE;
104 pCapturedImage->
pixels = (
unsigned char *) lpVHdr->lpData;
108 return (LRESULT) TRUE;
131 for (
int i = 0; i < 1024; i++)
132 m_clip[i] = i < 256 ? i : 255;
164 m_hCaptureWnd = capCreateCaptureWindow(
"Capture Window", 0, 0, 0, 640, 480, NULL, 0);
191 s.dwRequestMicroSecPerFrame = 41667;
192 s.fMakeUserHitOKToCapture = FALSE;
193 s.wPercentDropForError = 10;
195 s.dwIndexSize = 34952;
196 s.wChunkGranularity = 0;
197 s.fUsingDOSMemory = FALSE;
198 s.wNumVideoRequested = 10;
199 s.fCaptureAudio = FALSE;
201 s.vKeyAbort = VK_ESCAPE;
202 s.fAbortLeftMouse = FALSE;
203 s.fAbortRightMouse = FALSE;
204 s.fLimitEnabled = FALSE;
206 s.fMCIControl = FALSE;
210 s.fStepCaptureAt2x = FALSE;
211 s.wStepCaptureAverageFrames = 1;
212 s.dwAudioBufferSize = 0;
213 s.fDisableWriteCache = FALSE;
214 s.AVStreamMaster = AVSTREAMMASTER_NONE;
243 char szVersion[1000];
245 if (!capGetDriverDescription(nDriverIndex, szName,
sizeof(szName), szVersion,
sizeof(szVersion)))
258 CAPDRIVERCAPS gCapDriverCaps;
263 if (gCapDriverCaps.fHasDlgVideoFormat)
275 CAPDRIVERCAPS gCapDriverCaps;
280 if (gCapDriverCaps.fHasDlgVideoSource)
292 BITMAPINFO bitmapInfo;
296 m_nWidth = bitmapInfo.bmiHeader.biWidth;
297 m_nHeight = abs(bitmapInfo.bmiHeader.biHeight);
319 if (bitmapInfo.bmiHeader.biHeight > 0)
348 if (pCapturedImage && pCapturedImage->
pixels)
352 unsigned char *output = ppImages[0]->
pixels;
359 const unsigned char *
input = pCapturedImage->
pixels;
361 for (
int i = 0; i < nBytes; i += 3)
363 output[i] = input[i + 2];
364 output[i + 1] = input[i + 1];
365 output[i + 2] = input[i];
371 printf(
"error: BI_BITFIELDS not yet implemented\n");
379 const unsigned char *inputY = pCapturedImage->
pixels;
380 const unsigned char *inputU = inputY + nBytes;
381 const unsigned char *inputV = inputU + nBytes / 4;
388 int j = (h / 2) * (m_nWidth / 2) + (
w / 2);
389 yuv2rgb(inputY[i], inputU[j], inputV[j], &output[3 * i]);
397 const unsigned char *
input = pCapturedImage->
pixels;
399 for (
int i = 0; i < nBytes; i += 4)
401 unsigned char y0 = *input++;
402 unsigned char u = *input++;
403 unsigned char y1 = *input++;
404 unsigned char v = *input++;
void ShowVideoSourceDialog()
CVFWCapture(int nDriverIndex)
bool GetDriverName(int nDriverIndex, std::string &sName)
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
CByteImage::ImageType m_type
CRITICAL_SECTION critical_section
static void yuv2rgb(unsigned char y, unsigned char u, unsigned char v, unsigned char *out)
GLuint GLuint GLsizei GLenum type
unsigned char * pixels
The pointer to the the pixels.
bool FlipY(const CByteImage *pInputImage, CByteImage *pOutputImage)
Flips the rows in a CByteImage vertically and writes the result to a CByteImage.
bool CopyImage(const CByteImage *pInputImage, CByteImage *pOutputImage, const MyRegion *pROI=0, bool bUseSameSize=false)
Copies one CByteImage to another.
GLsizei const GLchar ** string
static CByteImage * pCapturedImage
GLenum GLsizei GLsizei height
GLenum GLenum GLenum input
ImageType type
The type of the image.
unsigned long m_nCompression
static LRESULT CALLBACK CallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr)
bool CaptureImage(CByteImage **ppImages)
void ShowVideoFormatDialog()
GLubyte GLubyte GLubyte GLubyte w