PDA

View Full Version : Splitting the video stream into multiple child windows



legionaire
March 18, 2004, 20:56:02
I am trying to distribute a single video stream into multiple child windows but have not been able to figure out how.

I am new to IC Imaging. Can you outline the steps I that I need to follow to accomplish this? Please be as detailed as possible.

Thanks.

Stefan Geissler
March 19, 2004, 10:38:48
Hello,

if you can retrieve the Device Contexts (HDC) of your child windows, you can blit the memory buffer, that is available in the frameReady event of GrabberListener into all of these DCs.


void CListener::frameReady( Grabber& param, smart_ptr<MemBuffer> pBuffer, DWORD FrameNumber)
{
TRACE("%d\n",FrameNumber);
pBuffer->lock();
DrawBuffer(pBuffer);
pBuffer->unlock();
}

void CListener::DrawBuffer( smart_ptr<MemBuffer> pBuffer)
{
if( m_pDrawCWnd != NULL)
{
if( pBuffer != 0 )
{
for( int i = 0; i < drawwndcount; i++)
{
CDC *pDC = m_pDrawCWnd[i]->GetDC();

smart_ptr<BITMAPINFOHEADER> pInf = pBuffer->getBitmapInfoHeader();

void* pBuf = pBuffer->getPtr();

int nLines = SetDIBitsToDevice(
pDC->GetSafeHdc(),// Handle to the device
0,
0,
pInf->biWidth, // Source rectangle width
pInf->biHeight, // Source rectangle height
0, // X-coordinate of lower-left corner of the source rect
0, // Y-coordinate of lower-left corner of the source rect
0, // First scan line in array
pInf->biHeight, // Number of scan lines
pBuffer->getPtr(), // Modified address of array with DIB bits
reinterpret_cast<LPBITMAPINFO>( &*pInf ), // Address of structure with bitmap info
DIB_RGB_COLORS // RGB or palette indices
);
m_pDrawCWnd[i]->ReleaseDC(pDC);
}
}
}
}



The m_pDrawCWnd should be a CWnd array, that contains all of you child windows, where
the live video should be displays.

legionaire
March 20, 2004, 03:21:14
For this part:

-------------------------------------------------------

void CListener::frameReady( Grabber& param, smart_ptr<MemBuffer> pBuffer, DWORD FrameNumber)
{
TRACE("%d\n",FrameNumber);
pBuffer->lock();
DrawBuffer(pBuffer);
pBuffer->unlock();
}

-----------------------------------------------------------

You lock the buffer, draw from it, and then unlock it?


Thanks for your code, I think I understand it now.


How about if I want to add different filters to each of these child windows? Such as one child window will have graphic overlay, another will display the image in grayscale, another will display the image in another scale with a portion of the image cut off etc...

And all of these child windows should draw off of the same video stream.

Is this possible to do? And if so, how should I start this?


Thanks.

Stefan Geissler
March 22, 2004, 08:56:45
Hello,

To see the why i do buffer locking, see here:
http://www.theimagingsourceforums.com/showthread.php?s=&threadid=315736

To solve your problem, you should create copies of the image buffers and send them to the specified filters. You may create a CWnd derived class, that implements the filters and the windows where to display the images.