Lines Matching defs:wcd

213     WndCameraDevice* wcd = (WndCameraDevice*)capGetUserData(hwnd);
216 if (wcd->last_frame_size < hdr->dwBytesUsed) {
217 wcd->last_frame_size = hdr->dwBytesUsed;
218 if (wcd->last_frame != NULL) {
219 free(wcd->last_frame);
221 wcd->last_frame = malloc(wcd->last_frame_size);
225 memcpy(wcd->last_frame, hdr->lpData, hdr->dwBytesUsed);
229 if (wcd->frame_bitmap->bmiHeader.biCompression == BI_RGB) {
230 if (wcd->frame_bitmap->bmiHeader.biBitCount == 32) {
231 wcd->pixel_format = V4L2_PIX_FMT_BGR32;
232 } else if (wcd->frame_bitmap->bmiHeader.biBitCount == 16) {
233 wcd->pixel_format = V4L2_PIX_FMT_RGB565;
235 wcd->pixel_format = V4L2_PIX_FMT_BGR24;
238 wcd->pixel_format = wcd->frame_bitmap->bmiHeader.biCompression;
251 WndCameraDevice* wcd;
254 wcd = _camera_device_alloc();
255 if (wcd == NULL) {
259 wcd->window_name = (name != NULL) ? ASTRDUP(name) :
261 if (wcd->window_name == NULL) {
263 _camera_device_free(wcd);
266 wcd->input_channel = inp_channel;
273 wcd->cap_window = capCreateCaptureWindow(wcd->window_name, WS_CHILD, 0, 0,
275 if (wcd->cap_window == NULL) {
277 __FUNCTION__, wcd->window_name, GetLastError());
278 _camera_device_free(wcd);
282 capSetUserData(wcd->cap_window, wcd);
284 return &wcd->header;
293 WndCameraDevice* wcd;
303 wcd = (WndCameraDevice*)cd->opaque;
305 /* wcd->dc is an indicator of capturing: !NULL - capturing, NULL - not */
306 if (wcd->dc != NULL) {
308 __FUNCTION__, wcd->window_name);
313 if (!capDriverConnect(wcd->cap_window, wcd->input_channel)) {
318 format_info_size = capGetVideoFormatSize(wcd->cap_window);
322 _camera_device_reset(wcd);
325 wcd->frame_bitmap = (BITMAPINFO*)malloc(format_info_size);
326 if (wcd->frame_bitmap == NULL) {
328 _camera_device_reset(wcd);
331 if (!capGetVideoFormat(wcd->cap_window, wcd->frame_bitmap,
334 _camera_device_reset(wcd);
339 if (wcd->frame_bitmap->bmiHeader.biWidth != frame_width ||
340 abs(wcd->frame_bitmap->bmiHeader.biHeight) != frame_height) {
342 wcd->frame_bitmap->bmiHeader.biWidth = frame_width;
343 wcd->frame_bitmap->bmiHeader.biHeight = frame_height;
346 if (wcd->frame_bitmap->bmiHeader.biBitCount == 24) {
349 wcd->frame_bitmap->bmiHeader.biSizeImage = bpl * frame_height;
351 wcd->frame_bitmap->bmiHeader.biSizeImage =
352 (frame_width * frame_height * wcd->frame_bitmap->bmiHeader.biBitCount) / 8;
354 if (!capSetVideoFormat(wcd->cap_window, wcd->frame_bitmap,
357 _camera_device_reset(wcd);
362 if (wcd->frame_bitmap->bmiHeader.biCompression > BI_PNG) {
364 __FUNCTION__, (const char*)&wcd->frame_bitmap->bmiHeader.biCompression);
372 if (wcd->frame_bitmap->bmiHeader.biHeight < 0) {
373 wcd->frame_bitmap->bmiHeader.biHeight =
374 -wcd->frame_bitmap->bmiHeader.biHeight;
375 wcd->is_top_down = 1;
377 wcd->is_top_down = 0;
382 wcd->dc = GetDC(wcd->cap_window);
383 if (wcd->dc == NULL) {
385 __FUNCTION__, wcd->window_name, GetLastError());
386 _camera_device_reset(wcd);
391 if (capCaptureGetSetup(wcd->cap_window, &cap_param, sizeof(cap_param))) {
396 capCaptureSetSetup(wcd->cap_window, &cap_param, sizeof(cap_param));
408 if (!capGrabFrameNoStop(wcd->cap_window) ||
409 !capEditCopy(wcd->cap_window) ||
410 !OpenClipboard(wcd->cap_window)) {
412 __FUNCTION__, wcd->window_name, GetLastError());
413 _camera_device_reset(wcd);
422 __FUNCTION__, wcd->window_name, GetLastError());
424 _camera_device_reset(wcd);
431 __FUNCTION__, wcd->window_name, GetLastError());
434 _camera_device_reset(wcd);
443 if (wcd->frame_bitmap->bmiHeader.biWidth != bitmap.bmWidth ||
444 wcd->frame_bitmap->bmiHeader.biHeight != bitmap.bmHeight ) {
447 wcd->frame_bitmap->bmiHeader.biWidth,
448 wcd->frame_bitmap->bmiHeader.biHeight);
449 _camera_device_reset(wcd);
454 wcd->gdi_bitmap = (BITMAPINFO*)malloc(wcd->frame_bitmap->bmiHeader.biSize);
455 if (wcd->gdi_bitmap == NULL) {
457 _camera_device_reset(wcd);
460 memcpy(wcd->gdi_bitmap, wcd->frame_bitmap,
461 wcd->frame_bitmap->bmiHeader.biSize);
462 wcd->gdi_bitmap->bmiHeader.biCompression = BI_RGB;
463 wcd->gdi_bitmap->bmiHeader.biBitCount = bitmap.bmBitsPixel;
464 wcd->gdi_bitmap->bmiHeader.biSizeImage = bitmap.bmWidthBytes * bitmap.bmWidth;
471 if (wcd->is_top_down) {
472 wcd->gdi_bitmap->bmiHeader.biHeight =
473 wcd->frame_bitmap->bmiHeader.biHeight;
475 wcd->gdi_bitmap->bmiHeader.biHeight =
476 -wcd->frame_bitmap->bmiHeader.biHeight;
480 wcd->framebuffer = (uint8_t*)malloc(wcd->gdi_bitmap->bmiHeader.biSizeImage);
481 if (wcd->framebuffer == NULL) {
483 __FUNCTION__, wcd->gdi_bitmap->bmiHeader.biSizeImage);
484 _camera_device_reset(wcd);
489 if (wcd->gdi_bitmap->bmiHeader.biBitCount == 16) {
490 wcd->pixel_format = V4L2_PIX_FMT_RGB565;
491 } else if (wcd->gdi_bitmap->bmiHeader.biBitCount == 24) {
492 wcd->pixel_format = V4L2_PIX_FMT_BGR24;
493 } else if (wcd->gdi_bitmap->bmiHeader.biBitCount == 32) {
494 wcd->pixel_format = V4L2_PIX_FMT_BGR32;
497 __FUNCTION__, wcd->gdi_bitmap->bmiHeader.biBitCount);
498 _camera_device_reset(wcd);
503 __FUNCTION__, wcd->window_name, wcd->gdi_bitmap->bmiHeader.biBitCount,
504 (const char*)&wcd->pixel_format, wcd->frame_bitmap->bmiHeader.biWidth,
505 wcd->frame_bitmap->bmiHeader.biHeight);
508 wcd->use_clipboard = 1;
509 if (capSetCallbackOnFrame(wcd->cap_window, _on_captured_frame)) {
511 wcd->use_clipboard = 0;
520 WndCameraDevice* wcd;
525 wcd = (WndCameraDevice*)cd->opaque;
528 capSetCallbackOnFrame(wcd->cap_window, NULL);
530 /* wcd->dc is the indicator of capture. */
531 if (wcd->dc == NULL) {
533 __FUNCTION__, wcd->window_name);
536 ReleaseDC(wcd->cap_window, wcd->dc);
537 wcd->dc = NULL;
540 _camera_device_reset(wcd);
549 _camera_device_read_frame_callback(WndCameraDevice* wcd,
559 if (!capGrabFrameNoStop(wcd->cap_window) || wcd->last_frame == NULL) {
561 __FUNCTION__, wcd->window_name, GetLastError());
566 return convert_frame(wcd->last_frame,
567 wcd->pixel_format,
568 wcd->frame_bitmap->bmiHeader.biSizeImage,
569 wcd->frame_bitmap->bmiHeader.biWidth,
570 wcd->frame_bitmap->bmiHeader.biHeight,
579 _camera_device_read_frame_clipboard(WndCameraDevice* wcd,
591 if (!capGrabFrameNoStop(wcd->cap_window) ||
592 !capEditCopy(wcd->cap_window) ||
593 !OpenClipboard(wcd->cap_window)) {
595 __FUNCTION__, wcd->window_name, GetLastError());
604 __FUNCTION__, wcd->window_name, GetLastError());
611 if (wcd->gdi_bitmap->bmiHeader.biHeight > 0) {
612 wcd->gdi_bitmap->bmiHeader.biHeight = -wcd->gdi_bitmap->bmiHeader.biHeight;
615 if (!GetDIBits(wcd->dc, bm_handle, 0, wcd->frame_bitmap->bmiHeader.biHeight,
616 wcd->framebuffer, wcd->gdi_bitmap, DIB_RGB_COLORS)) {
618 __FUNCTION__, wcd->window_name, GetLastError());
624 if (wcd->gdi_bitmap->bmiHeader.biHeight < 0) {
625 wcd->gdi_bitmap->bmiHeader.biHeight = -wcd->gdi_bitmap->bmiHeader.biHeight;
632 return convert_frame(wcd->framebuffer,
633 wcd->pixel_format,
634 wcd->gdi_bitmap->bmiHeader.biSizeImage,
635 wcd->frame_bitmap->bmiHeader.biWidth,
636 wcd->frame_bitmap->bmiHeader.biHeight,
650 WndCameraDevice* wcd;
657 wcd = (WndCameraDevice*)cd->opaque;
658 if (wcd->dc == NULL) {
660 __FUNCTION__, wcd->window_name);
666 return wcd->use_clipboard ?
667 _camera_device_read_frame_clipboard(wcd, framebuffers, fbs_num, r_scale,
669 _camera_device_read_frame_callback(wcd, framebuffers, fbs_num, r_scale,
680 WndCameraDevice* wcd = (WndCameraDevice*)cd->opaque;
681 _camera_device_free(wcd);
713 WndCameraDevice* wcd = (WndCameraDevice*)cd->opaque;
728 cis[found].pixel_format = wcd->pixel_format;