Hallo,
hier sind source auszüge.
Aber nicht kommerziell nutzen
ich hoffe es hilft dirCode:STDMETHODIMP BufferCB( double SampleTime, BYTE * pBuffer, long BufferSize ) { if(g_bWantBimap) { CBitmapData* pBitmapData = new CBitmapData; if (!pBuffer) return E_POINTER; if( pBitmapData->lBufferSize < BufferSize) { if (pBitmapData->pBuffer) { delete [] pBitmapData->pBuffer; } pBitmapData->pBuffer = NULL; pBitmapData->lBufferSize = 0; } // Since we can't access Windows API functions in this callback, just // copy the bitmap data to a global structure for later reference. pBitmapData->dblSampleTime = SampleTime; // If we haven't yet allocated the data buffer, do it now. // Just allocate what we need to store the new bitmap. if (!pBitmapData->pBuffer) { pBitmapData->pBuffer = new BYTE[BufferSize]; pBitmapData->lBufferSize = BufferSize; } if( !pBitmapData->pBuffer ) { pBitmapData->lBufferSize = 0; return E_OUTOFMEMORY; } // Copy the bitmap data into our global buffer memcpy(pBitmapData->pBuffer, pBuffer, BufferSize); pBitmapData->Height = Height; pBitmapData->Width = Width; // Post a message to our application, telling it to come back // and write the saved data to a bitmap file on the user's disk. PostThreadMessage(m_pRoboControlThreadId, WM_CAPTURE_BITMAP, NULL, (long)pBitmapData); g_bWantBimap = FALSE; } return S_OK; } das ist die routine wo das bild verschickt wird class CBitmapData { public: CBitmapData(); virtual ~CBitmapData(); double dblSampleTime; long lBufferSize; BYTE *pBuffer; BITMAPINFOHEADER bih; long Width; long Height; }; hier ist das bimapt drin m_pGrabber->SetOneShot(FALSE); m_pGrabber->SetBufferSamples(TRUE); m_pGrabber->SetCallback(&g_CB, 1); // 0 = Use the SampleCB callback method. hier wird der grapper über geben und der Mode bestimmt // Jetzt den Framegrapper auf bauen if (!m_pGrabber) { hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber ); } CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber ); CMediaType VideoType; VideoType.SetType( &MEDIATYPE_Video ); VideoType.SetSubtype( &MEDIASUBTYPE_RGB24 ); hr = m_pGrabber->SetMediaType( &VideoType ); // shouldn't fail hr = pFg->AddFilter( pGrabBase, L"Grabber" ); // ende das baut den grapper zu sammen
wenn du mein test prg haben willst da sag bescheit





Zitieren

Lesezeichen