Ejemplo n.º 1
0
//Description: the start and end function of a DLL
//Input: instance, reason for being called
//Output: nothing important
BOOL APIENTRY CALLBACK DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) {
	
	//select the proper action to execute based on the reason for being called
	switch(fdwReason) {
	case DLL_THREAD_ATTACH:
		break;
	case DLL_THREAD_DETACH:
		break;
	//when a process attaches to the DLL, create the events and initialize the variables
	//for that process
	case DLL_PROCESS_ATTACH:
		hEventOKToUpdate = CreateEvent(NULL, TRUE, TRUE, NULL);
		hEventOKToGrab = CreateEvent(NULL, TRUE, FALSE, NULL);
		pImage = NULL;
		hWndC = NULL;
		dwSize = 0;
		break;
	//when a process detaches from the DLL, stop any image capturing and destroy the window;
	//note that the window must be disconnected from the imaging device before this message
	//is passed otherwise a DLL_THREAD_DETACH message is sent and the DLL gets stuck;
	//the close function MUST be called before the process is detached or else a crash will
	//occur
	case DLL_PROCESS_DETACH:
		capSetCallbackOnFrame(hWndC, NULL);
		capPreview(hWndC, FALSE);
		DestroyWindow(hWndC);
		hWndC = NULL;
		dwSize = 0;
		break;
	}
	return TRUE;
}
Ejemplo n.º 2
0
void CWinVideoGrabber::StopPreviewing()
{
	if (!inited) return;
	if (videomode == VIDEOGRABBERMODE_PREVIEWING){
	capPreview(videowindow, FALSE);
	videomode = VIDEOGRABBERMODE_NONE;
	}
}
Ejemplo n.º 3
0
void CWinVideoGrabber::StartPreviewing()
{
	if (!inited) return;
	StopPreviewing();
	StopRecording();
	videomode = VIDEOGRABBERMODE_PREVIEWING;
	capPreview(videowindow, True);
}
Ejemplo n.º 4
0
static int vfw_init (zbar_video_t *vdo,
                     uint32_t fmt)
{
    if(vfw_set_format(vdo, fmt))
        return(-1);

    HWND hwnd = vdo->state->hwnd;
    CAPTUREPARMS cp;
    if(!capCaptureGetSetup(hwnd, &cp, sizeof(cp)))
        return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_WINAPI, __func__,
                           "retrieving capture parameters"));

    cp.dwRequestMicroSecPerFrame = 33333;
    cp.fMakeUserHitOKToCapture = 0;
    cp.wPercentDropForError = 90;
    cp.fYield = 1;
    cp.wNumVideoRequested = vdo->num_images;
    cp.fCaptureAudio = 0;
    cp.vKeyAbort = 0;
    cp.fAbortLeftMouse = 0;
    cp.fAbortRightMouse = 0;
    cp.fLimitEnabled = 0;

    if(!capCaptureSetSetup(hwnd, &cp, sizeof(cp)))
        return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_WINAPI, __func__,
                           "setting capture parameters"));

    if(!capCaptureGetSetup(hwnd, &cp, sizeof(cp)))
        return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_WINAPI, __func__,
                           "checking capture parameters"));

    /* ignore errors since we skipped checking fHasOverlay */
    capOverlay(hwnd, 0);

    if(!capPreview(hwnd, 0) ||
       !capPreviewScale(hwnd, 0))
        err_capture(vdo, SEV_WARNING, ZBAR_ERR_WINAPI, __func__,
                    "disabling preview");

    if(!capSetCallbackOnVideoStream(hwnd, vfw_stream_cb) ||
       !capSetCallbackOnError(hwnd, vfw_error_cb))
        return(err_capture(vdo, SEV_ERROR, ZBAR_ERR_BUSY, __func__,
                           "setting capture callbacks"));

    vdo->num_images = cp.wNumVideoRequested;
    vdo->iomode = VIDEO_MMAP; /* driver provides "locked" buffers */

    zprintf(3, "initialized video capture: %d buffers %ldms/frame\n",
            vdo->num_images, cp.dwRequestMicroSecPerFrame);

    return(0);
}
//
// Standard AVIcap window message 
// macro: capPreview
BOOL	CAviCap::StartPreview(BOOL offOn)
{
	CHECKWIN();
	CHECKCNCT();
	if(_fPreviewIsOn==offOn)	return TRUE;
	if(capPreview(GetSafeHwnd(), offOn))
		{
		_fPreviewIsOn=offOn;
		return TRUE;}
	
	return FALSE;
	
}
Ejemplo n.º 6
0
/**
 * Stop previewing
 */
static javacall_result camera_stop(javacall_handle handle)
{
    camera_handle* pHandle = (camera_handle*)handle;
    BOOL ret = FALSE;

    JAVA_DEBUG_PRINT1("[camera] camera_stop %d %d\n", pHandle->hCapWnd);

    if (NULL != pHandle->hCapWnd) {
        ret = capPreview(pHandle->hCapWnd, FALSE);
    }

    return (TRUE == ret ? JAVACALL_OK : JAVACALL_FAIL);
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------
//카메라 초기화.
bool CWebCam::StartCam(CWnd* wnd, int nWidth, int nHeight, BITMAPINFO& bmpInfo) //wnd :캡처하는 영상이 나타날, 윈도우의 포인터를 넘겨받는다. 
                                                                                // bmpInfo : 영상의 규격을 얻는것 , 크래스 외부에서 작업을 수행할 수 있다.
{
	// 캡쳐 영상을 출력할 윈도우의 크기 및 위치 조절
	m_hCam = capCreateCaptureWindow("Cam Capture", WS_CHILD | WS_VISIBLE,
		0, 0, nWidth, nHeight, wnd->m_hWnd, NULL);   // 유니코드 지원 여부에 따라 각각 함수 실행. 촬영하는 영상의 규격과는 상관이 없다. 

	if (!capDriverConnect(m_hCam, 0))                //캡처 윈도우를 카메라와 연결한다. 
	{
		AfxMessageBox("연결된 카메라를 찾을 수 없습니다.");
		return false;
	}

	//	capDlgVideoFormat(m_hCam);
	capGetVideoFormat(m_hCam, &bmpInfo, sizeof(BITMAPINFO));     //캡처영상을 사용하려면 영상의 규격정보를 알아야한다. 

	// 캡쳐 영상의 크기를 희망 값으로 설정
	bmpInfo.bmiHeader.biWidth = nWidth;
	bmpInfo.bmiHeader.biHeight = nHeight;
	bmpInfo.bmiHeader.biSizeImage = nWidth*nHeight*bmpInfo.bmiHeader.biBitCount / 8;

	if (!capSetVideoFormat(m_hCam, &bmpInfo, sizeof(BITMAPINFO)))  //카메라의 영상 규격(크기와 색 형식 정보등)을 설정한다. 
	{
		// 설정에 실패하면 원래 값으로 되돌림
		capGetVideoFormat(m_hCam, &bmpInfo, sizeof(BITMAPINFO));
	}

	// 캡쳐 영상이 24비트 RGB가 될 수 있도록 설정
	bmpInfo.bmiHeader.biBitCount = 24;
	bmpInfo.bmiHeader.biCompression = BI_RGB;
	if (!capSetVideoFormat(m_hCam, &bmpInfo, sizeof(BITMAPINFO)))
	{
		// 설정에 실패하면 원래 값으로 되돌림
		capGetVideoFormat(m_hCam, &bmpInfo, sizeof(BITMAPINFO));
	}

	capOverlay(m_hCam, TRUE); //그래픽 하드웨어를 이용할 것인지 결정.   *오버레이를 활성화하면 미리보기가 자동으로 비활성화됨.
	capPreviewRate(m_hCam,30); //미리보기를 갱신하는 시간 간격을 설정.
	capPreview(m_hCam, TRUE);   //미리보기를 활성화 할 것인지 결정.

	return true;
}
Ejemplo n.º 8
0
//Description: sets up an imaging device for capture operations
//Input: digitizer ID number and a dummy string
//Output: returns success (non-negative) or failure
EXPORT long SetUp(long driver, long width, long height){

	//reset the image and size variables
	pImage = NULL;
	dwSize = 0;

	//make sure we don't already have a window
	if(hWndC == NULL) {
		//create the capture window, the window is currently being draw in the top left corner
		//because the buffer is filled with nothing if it is not being drawn on the screen;
		//only a window size of 1x1 is needed to get this to work
		hWndC = capCreateCaptureWindow(TEXT("Webcam Capture Window"), WS_CHILD | WS_VISIBLE, 0, 0,
			1, 1, GetDesktopWindow(), 0); 
	}

	//connect the selected driver to the window
	if(!capDriverConnect(hWndC, driver)) {
		DestroyWindow(hWndC);
		return -1;
	}

	//create a frame capture callback function
	if(!capSetCallbackOnFrame(hWndC, capFrame)) {
		capDriverDisconnect(hWndC);
		DestroyWindow(hWndC);
		return -1;
	}


	//begin previewing
	capPreviewRate(hWndC, 66);
	if(!capPreview(hWndC, TRUE)) {
		capDriverDisconnect(hWndC);
		DestroyWindow(hWndC);
		return -1;
	}

	return 0;
}
Ejemplo n.º 9
0
/*初始化VFW设备*/ 
void CMainFrame::OnVfwInitvfw()
{
	// TODO: 在此添加命令处理程序代码
	DWORD fsize;

	// 创建视频窗口
	if(!m_wndSource.CreateEx(WS_EX_TOPMOST,NULL,
							_T("Source"),WS_OVERLAPPED|WS_CAPTION,
							CRect(0,0,352,288),NULL,0))
		return;
	
	m_hWndCap = capCreateCaptureWindow(_T("Capture Window"),WS_CHILD|WS_VISIBLE,
									  0,0,352,288,
									  m_wndSource.m_hWnd,0);

	//m_wndSource.ShowWindow(SW_SHOW);
	// 注册回调函数
	capSetCallbackOnError(m_hWndCap,(FARPROC)ErrorCallbackProc);
	capSetCallbackOnStatus(m_hWndCap,(FARPROC)StatusCallbackProc);
	capSetCallbackOnVideoStream(m_hWndCap,(FARPROC)VideoCallbackProc);

	// 连接视频设备
	capDriverConnect(m_hWndCap,0);	//(HWND m_hWndCap, int index);//index : 0--9
	// 获取驱动器的性能参数
	capDriverGetCaps(m_hWndCap,&m_caps,sizeof(CAPDRIVERCAPS));
	if (m_caps.fHasOverlay)
		capOverlay(m_hWndCap,TRUE);
	// 设置预览速率开始预览
	capPreviewRate(m_hWndCap,1000/25);
	capPreview(m_hWndCap,bPreview);


	fsize = capGetVideoFormatSize(m_hWndCap);
	capGetVideoFormat(m_hWndCap, lpbiIn, fsize);
	
	AfxMessageBox(_T("初始化成功!"));
}
Ejemplo n.º 10
0
bool fInitCamera (HWND hMainWnd, int iDeviceIndex)
{
// Create a capture window to capture the output from the camera
// The capture window is not actually displayed (in this application)

hgCapWnd = capCreateCaptureWindow(NULL,
                                  WS_CHILD,         // window style
                                  0, 0, 0, 0,       // position and size
                                  hMainWnd, ID_CAP);
if (!hgCapWnd)
    {
    Err("Can't open the camera display window");
    return 0;
    }
if (!capDriverConnect(hgCapWnd, iDeviceIndex))
    {
    Err("Can't connect to the camera");
    return false;
    }
if (!capDriverGetCaps(hgCapWnd, &gDriverCaps, sizeof(CAPDRIVERCAPS)))
    {
    Err("Can't get capabilities of the camera");
    return false;
    }
if (!capPreview(hgCapWnd, FALSE))   // turn off preview
    {
    Err("capPreview FALSE failed");
    return false;
    }
if (!capGetStatus(hgCapWnd, &gCapStatus, sizeof(CAPSTATUS)))
    {
    Err("Can't get status of the camera");
    return false;
    }
PrintCapStatus();
return true;    // success
}
Ejemplo n.º 11
0
/**
 * Start previewing
 */
static javacall_result camera_start(javacall_handle handle)
{
    camera_handle* pHandle = (camera_handle*)handle;

    JAVA_DEBUG_PRINT2("[camera] camera_start %d %d\n", 
        pHandle->hCapWnd, pHandle->visible);

    /* Preview start only if there is preview window and visible is TRUE */
    if (NULL != pHandle->hCapWnd && JAVACALL_TRUE == pHandle->visible) {
        if (TRUE == capPreview(pHandle->hCapWnd, TRUE))
            return JAVACALL_OK;
        else
            return JAVACALL_FAIL;
    } else if (NULL == pHandle->hCapWnd) {
        /* If there is no camera preview window, 
        * create it with default position and size */
        HWND hCapWnd = camera_set_preview_window(
            handle, pHandle->x, pHandle->y, pHandle->w, pHandle->h, FALSE);
        if (NULL == hCapWnd) 
            return JAVACALL_FAIL;
    }

    return JAVACALL_OK;
}
		int   
			STVideoCapture::Initialize
			( 
            HWND hwndParentWindow, // This must be non-null
            STVideoCaptureFormat videoCaptureFormat,
            int capturePeriodMilliseconds,
			STVideoCaptureClient * pSTVideoCaptureClient
			)
		{
			(*this).Clear();




            // Validate capture format
            int captureWidth = 0;
            int captureHeight = 0;
            switch (videoCaptureFormat)
            {
			case BGR320x240: { captureWidth = 320; captureHeight = 240; } break;
            }

            if ((0 == captureWidth) || (0 == captureHeight))
            {
                printf( "Invalid capture format." );
                (*this).Clear();
                return (FALSE);
            }
            (*this).mSTVideoCaptureFormat = videoCaptureFormat;




            // We create a capture window only because we are required to create
            // such a window to use the Video for Windows (VFW32) API.  We make
            // this window tiny to keep it out of the way of our application.
            // For our purposes, this window is simply a necessary interface to
            // VFW functionality.
            (*this).mHWNDCapture =
                capCreateCaptureWindowA
                (
                    "STVideoCapture Window",
                    (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS), // style
                    0, // x
                    0, // y
                    4, // width
                    4, // height
                    hwndParentWindow, // Parent window : This must be non-null
                    0 // nID
                );



			if (((HWND)(0)) == (*this).mHWNDCapture)
			{ 
                printf( "Failed to create video capture window." );
                DestroyWindow( (*this).mHWNDCapture );
                (*this).Clear();
                return (FALSE);
			}




			(*this).mCapDriverConnectStatus = capDriverConnect( (*this).mHWNDCapture, 0 );

            if (0 == (*this).mCapDriverConnectStatus)
            {
                printf( "Failed to connect to video driver." );
                DestroyWindow( (*this).mHWNDCapture );
                (*this).Clear();
                return (FALSE);
            }



			CAPDRIVERCAPS  capdrivercaps;
			memset( (&(capdrivercaps)),   0,  sizeof(capdrivercaps) );
			capDriverGetCaps( (*this).mHWNDCapture, &(capdrivercaps), sizeof(capdrivercaps) );




			//capDlgVideoFormat( mHWNDCapture );
			//capDlgVideoSource( mHWNDCapture );  // Source; Brightness, Contrast, Saturation, Exposure



            // Allocate a local buffer to store capture data
            int bytesPerPixel = 3;
            switch (videoCaptureFormat)
            {
			case BGR320x240: { bytesPerPixel = 3; } break;
            }
            int totalImageBytes = 0;
            totalImageBytes = (captureHeight * (captureWidth * bytesPerPixel));
            (*this).mBGRData = (unsigned char *) malloc( totalImageBytes );
			memset( (*this).mBGRData,   0,  totalImageBytes );



			// Set the video stream callback function
			(*this).mpSTVideoCaptureClient = pSTVideoCaptureClient;
			capSetCallbackOnFrame( (*this).mHWNDCapture, STVideoCapture::CommonCaptureCallback );


			// Set the preview rate in milliseconds
            (*this).mCapturePeriodMilliseconds = capturePeriodMilliseconds;
            capPreviewRate( (*this).mHWNDCapture, capturePeriodMilliseconds );


			// Disable preview mode
			capPreview( (*this).mHWNDCapture, FALSE );


			// Setup the data we want returned to us
			BITMAPINFO  capbitmapinfo;
			memset( &(capbitmapinfo), 0, sizeof(BITMAPINFO) );
			capbitmapinfo.bmiHeader.biSize           = sizeof(BITMAPINFOHEADER);
			capbitmapinfo.bmiHeader.biWidth          = captureWidth;
			capbitmapinfo.bmiHeader.biHeight         = captureHeight;
			capbitmapinfo.bmiHeader.biPlanes         =  1;
			capbitmapinfo.bmiHeader.biBitCount       = 24;
			capbitmapinfo.bmiHeader.biCompression    = BI_RGB;
			capbitmapinfo.bmiHeader.biSizeImage      = totalImageBytes;
			capbitmapinfo.bmiHeader.biXPelsPerMeter  = 100;
			capbitmapinfo.bmiHeader.biYPelsPerMeter  = 100;

			BOOL setVideoFormatResult = FALSE;
			setVideoFormatResult = capSetVideoFormat( (*this).mHWNDCapture, &(capbitmapinfo), sizeof(BITMAPINFO) );

            if (FALSE == setVideoFormatResult)
            {
                printf( "Failed to set the desired video capture format." );
                capSetCallbackOnFrame( (*this).mHWNDCapture, NULL ); // disable the callback function
                DestroyWindow( (*this).mHWNDCapture );
                (*this).Clear( );
                return (FALSE);
            }


			return( TRUE );
		} 
BOOL CWebCam::StopRecord()
{
	capCaptureStop(m_hCam); //캡처동작 정지. 캡처한 영상을 파일에 저장. 

	return capPreview(m_hCam, TRUE);
}
Ejemplo n.º 14
0
	void CSoCProjectView::OnInitialUpdate()
	{
		CScrollView::OnInitialUpdate();

		CSize sizeTotal;
		// TODO: 이 뷰의 전체 크기를 계산합니다.
		sizeTotal.cx = 640;
		sizeTotal.cy = 480;
		SetScrollSizes(MM_TEXT, sizeTotal);

		CSoCProjectDoc*pDoc = GetDocument();
		// TODO: 여기에 생성 코드를 추가합니다.
		RECT r;
		GetClientRect(&r);
		pDoc->m_hCamWnd = capCreateCaptureWindow(
			_T("Capture Window"), WS_CHILD | WS_VISIBLE, 5, 5, r.right-5, r.bottom-5, this->m_hWnd, NULL);

		// 설치된 디바이스를 순서로 0 ~ 9까지의 카메라를 지정 할 수 있다.
		if(!capDriverConnect(pDoc->m_hCamWnd, 0)) AfxMessageBox(_T("웹캠 인식 실패 ㅠㅠ"));

		// 현재 드라이버 정보에 관한 내용 얻어오기
		capDriverGetCaps(pDoc->m_hCamWnd, &pDoc->m_psCapsInfo, sizeof(pDoc->m_psCapsInfo));

		//비디오 포맷 변환을 지원하는지 확인한다.
		if(pDoc->m_psCapsInfo.fHasDlgVideoFormat) {
			// 비디오 포맷 변환을 지원하면 아래 함수를 호출한다.
			// 호출되는 함수는 새로운 다이얼로그를 호출하고 해상도와 포맷형식, 프레임 버퍼크기등을 지정할 수 있다.
			// 이때, 지원되지 않는 비디오포멧을 설정하면 검정 화면을 보게될 것이야...
			capDlgVideoFormat(pDoc->m_hCamWnd);
		}

		// m_psCapsInfo.fHasOverlay에서 overlay가 지원이 되지 않으면(=0) 사용 할 수 없다.
		if(pDoc->m_psCapsInfo.fHasOverlay) {
			// 하드웨어 오버레이는 시스템 부하를 줄여준다.(optioinal)
			capOverlay(pDoc->m_hCamWnd, FALSE);
		}

		// BITMAPINFO 설정
		capGetVideoFormat(pDoc->m_hCamWnd, &pDoc->m_BTMInfo, sizeof(pDoc->m_BTMInfo));

		// 1/1000 단위로 영상이 출력된다.
		capPreviewRate(pDoc->m_hCamWnd, 1);

		// 프리뷰 영상을 재생한다.
		capPreview(pDoc->m_hCamWnd, TRUE);

		CAPTUREPARMS cp;     
	
		capCaptureGetSetup(pDoc->m_hCamWnd, &cp, sizeof(cp) );	// get the current defaults      
	
		cp.dwRequestMicroSecPerFrame = 1;					// Set desired frame rate     
		cp.fMakeUserHitOKToCapture   = FALSE;
		cp.fYield                    = TRUE;                // we want capture on a background thread.
		cp.wNumVideoRequested        = (WORD) 1;			// we may get less than this - no problem
		cp.fCaptureAudio             = FALSE;     
		cp.vKeyAbort                 = 0;                   // If no key is provided, it won't stop...
		cp.fAbortLeftMouse           = FALSE;
		cp.fAbortRightMouse          = FALSE;
		cp.fLimitEnabled             = FALSE;				// we want to stop     
		cp.fMCIControl               = FALSE;
	
		capCaptureSetSetup(pDoc->m_hCamWnd, &cp, sizeof(cp) ); 
		
		capSetCallbackOnVideoStream(pDoc->m_hCamWnd, VideoCallbackProc);
		capSetCallbackOnFrame(pDoc->m_hCamWnd, VideoCallbackProc);
	}
Ejemplo n.º 15
0
long __stdcall DlgProc ( HWND hWnd , unsigned msg , unsigned wParam , long lParam )
{ 
   switch(msg)
   {
      case WM_INITDIALOG: 
			//hEdit = GetDlgItem( hWnd , I_EDIT );  
			//GetClientRect( hEdit , &rect );
			hWndCap = capCreateCaptureWindow ( NULL, WS_CHILD | WS_VISIBLE , 0, 0, 320, 240, hWnd, 1235 );
			//hWndCap = capCreateCaptureWindow ( NULL, WS_CHILD | WS_VISIBLE , 0, 0, (rect.right-rect.left ), (rect.bottom-rect.top), hEdit, 1235);
						
			// вручную заполняем структуру CapVar
			ZeroMemory( &CapVar, sizeof(COMPVARS) );   
			CapVar.cbSize = sizeof(COMPVARS);
			CapVar.dwFlags = ICMF_COMPVARS_VALID;   
			CapVar.cbState = 0;   
			CapVar.fccHandler = mmioFOURCC( 'x', '2', '6', '4' );   
			CapVar.fccType = ICTYPE_VIDEO;

			// открываем декомпрессор (долго)
			CapVar.hic = ICOpen( ICTYPE_VIDEO, CapVar.fccHandler, ICMODE_COMPRESS ); 

			hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)SendThread, NULL, 0, 0 );
						
			return -1 ;

      case WM_COMMAND:
			switch(LOWORD(wParam))			
			{
				case I_BUTTON_CONN :

					if( !capDriverConnect( hWndCap, 0 ) )
               {
                  EndDialog ( hWnd, 0 );
                  return -1;
               }
									
					capCaptureGetSetup( hWndCap, &CapParms, sizeof(CAPTUREPARMS) );        
   
					CapParms.dwRequestMicroSecPerFrame = 66000;    
					CapParms.fLimitEnabled = FALSE;     
					CapParms.fCaptureAudio = FALSE;    
					CapParms.fMCIControl = FALSE;     
					CapParms.fYield = TRUE;      
					CapParms.vKeyAbort = VK_ESCAPE;    
					CapParms.fAbortLeftMouse = FALSE;    
					CapParms.fAbortRightMouse = FALSE;    
					capCaptureSetSetup( hWndCap, &CapParms, sizeof(CAPTUREPARMS) );    
     
					capPreviewScale( hWndCap, 1 );     
					capPreviewRate( hWndCap, 66 );     
					capPreviewScale( hWndCap, FALSE );    
					capPreview( hWndCap, 1 );    
									
					//added by jimmy 

					// OPTIONAL STEP: Setup resolution
					capGetVideoFormat( hWndCap, &InputBmpInfo ,sizeof(InputBmpInfo) );
					//InputBmpInfo.bmiHeader.biWidth = 320; //(rect.right-rect.left );
					//InputBmpInfo.bmiHeader.biHeight = 240; //(rect.bottom-rect.top);
					//InputBmpInfo.bmiHeader.biBitCount = 24;
					capSetVideoFormat( hWndCap, &InputBmpInfo, sizeof(InputBmpInfo) );
					//capDriverDisconnect (hWndCap, 0);//Can we do better?
					//capDriverConnect (hWndCap, 0);

					capSetCallbackOnFrame( hWndCap, FrameCallBack ); 									

					if(CapVar.hic > 0 )   
					{  
						OutFormatSize = ICCompressGetFormatSize( CapVar.hic, &InputBmpInfo.bmiHeader );   // BITMAPINFO возвращает размер структуры исходных данных InputBmpInfo
						ICCompressGetFormat( CapVar.hic, &InputBmpInfo.bmiHeader, &OutputBmpInfo.bmiHeader );   //  заполняет структуру получаемых данных OutputBmpInfo
						OutBufferSize = ICCompressGetSize( CapVar.hic, &InputBmpInfo.bmiHeader, &OutputBmpInfo.bmiHeader );   // максимальный размер одного сжатого кадра (полученного)
						ICSeqCompressFrameStart( &CapVar, &InputBmpInfo );  // начало сжатия 
					}

					break;

				case I_BUTTON_EXIT :

					ICSeqCompressFrameEnd(&CapVar);   // конец сжатия
					ICCompressorFree(&CapVar);   
					ICClose(CapVar.hic);  

					capPreview( hWndCap , false );		
					capDriverDisconnect( hWndCap );

					EndDialog ( hWnd , 0 ) ;									
					break;

			}
		   return -1 ;	

      case WM_CLOSE :

			ICSeqCompressFrameEnd(&CapVar);   // конец сжатия
			ICCompressorFree(&CapVar);   
			ICClose(CapVar.hic);  

			capPreview( hWndCap , false );		
			capDriverDisconnect( hWndCap );
				
			EndDialog ( hWnd , 0 ) ;
         return -1 ;

   }

   return 0 ;
}