Friday, March 30, 2007

Desktop screen capture source filter…

Desktop screen capture filter…


HWND hwndDesktop = GetDesktopWindow();
HDC hdcDesktop = GetDC(hwndDesktop);

//BitBlt(m_hdcPaint,0,0,300,300,hdcDesktop,0,0,SRCCOPY);
StretchBlt(m_hdcPaint,0,0,300,300,hdcDesktop,0,0,720,480,SRCCOPY) ;
CopyMemory(pBuffer,m_pPaintBuffer,pSample->GetSize());
ReleaseDC(hwndDesktop,hdcDesktop);

HRESULT CMySourceStream::FillBuffer(IMediaSample *pSample)
{

try
{
CAutoLock lock(m_pFilter->pStateLock());
HRESULT hr = S_OK;
BYTE* pBuffer;
char szDisplay[MAX_PATH];
OutputDebugString("\n CMySourceStream::FillBuffer() fn");
hr = pSample->GetPointer(&pBuffer);

if(SUCCEEDED(hr))
{
sprintf(szDisplay,"%d", m_lFrameCount++);
TextOut(m_hdcPaint,100,100,szDisplay,strlen(szDisplay));
HWND hwndDesktop = GetDesktopWindow();
HDC hdcDesktop = GetDC(hwndDesktop);
// BitBlt(m_hdcPaint,0,0,300,300,hdcDesktop,0,0,SRCCOPY);
StretchBlt(m_hdcPaint,0,0,300,300,hdcDesktop,0,0,720,480,SRCCOPY);
CopyMemory(pBuffer,m_pPaintBuffer,pSample->GetSize());
ReleaseDC(hwndDesktop,hdcDesktop);
}

return hr;
}
catch(...)
{
OutputDebugString("\n Error in CMySourceStream::FillBuffer() fn");
return E_FAIL;
}
}

No comments: