Capture Function

capSetCallbackOnFrame(HWND   , &FrameCallBack);
 

LRESULT CALLBACK FrameCallBack( HWND hwnd, Longint lpvhdr )
{
    static BITMAPINFOHEADER BitmapHead;
    static BITMAPINFO BitmapInfo;
    static BITMAPFILEHEADER BitmapFileHead;
    CAPSTATUS status;
    int BIHsize, byte;
    Byte *ptr;
    TMemoryStream *stream = new TMemoryStream;

    VideoStr=LPVIDEOHDR(lpvhdr);
    capGetStatus( hwnd, &status, sizeof(status) ) ;
    BIHsize=capGetVideoFormatSize( hwnd);
    capGetVideoFormat( hwnd, &BitmapHead, BIHsize);
    BitmapInfo.bmiHeader=BitmapHead;

    stream->Size=sizeof(BitmapFileHead) + sizeof(BitmapHead) +                         BitmapHead.biSizeImage;

    BitmapFileHead.bfType=0x4D42;
    BitmapFileHead.bfSize=stream->Size;
    BitmapFileHead.bfOffBits=sizeof(BitmapFileHead) + sizeof(BitmapHead);
    stream->Position=0;
    stream->WriteBuffer( &BitmapFileHead, sizeof(BitmapFileHead) );
    stream->WriteBuffer( &BitmapInfo, sizeof(BitmapInfo) );
    (void*)ptr=stream->Memory;
    ptr += BitmapFileHead.bfOffBits;
    Move( VideoStr->lpData, ptr, BitmapHead.biSizeImage);
    stream->Position=0;
    // Display  圖的 Image
    fom_Main->Image3->Picture->Bitmap->LoadFromStream( stream );

    delete( stream );
    capSetCallbackOnFrame (hwnd, NULL); //°±¤îcallbackonframe
    return(0);
}

kenny23 發表在 痞客邦 PIXNET 留言(0) 人氣()