Page 1 of 1
camera->DrawFrame() in new SDK
Posted: Sun Nov 14, 2010 10:23 pm
I am porting my application to the new SDK, however I am having trouble displaying the image on a vc++ picturebox.
I am using the following:
however once I have the imageBuffer I don't know what to do with it in order to display this on a picturebox.
With the old SDK I could use the following:
where tempHandle is a handle to the picturebox
Thank You for any Help!
Re: camera->DrawFrame() in new SDK
Posted: Mon Nov 15, 2010 3:34 pm
Essentially, the rasterize function lets you populate a memory buffer with image data. It's designed so that you can specify 8,16,24, or 32 bit per pixel formats and varying row spans as well, which covers nearly 100% of the use patterns.
One of the most user friendly ways to manage this image data is to create one of our CameraLibrary::Bitmap objects, like we do in the sample code you're using, and rasterize into it. Our Bitmap class also has a 'GetBits' method which allows the user to get a pointer to the raw data which can then be pumped over to a CBITMAP for example for pushing to the UI.
Here's a little snippit of code that we've used in the past that should help you get the data into your object for display.
void DrawBitmap( Frame *frame, HWND hwnd )
CWnd * pWnd = CWnd::FromHandle(hwnd);
pt.x = m_rectBitmap.left;
pt.y = m_rectBitmap.top;
if ( !pWnd->GetSafeHwnd() )
int colorDepth = dc.GetDeviceCaps( BITSPIXEL );
m_viewBitmap.CreateBitmap( m_bitmap->PixelWidth(), m_bitmap->PixelHeight(), 1, m_bitmap->GetBitsPerPixel(), 0 );
m_viewBitmap.SetBitmapBits( m_bitmap->PixelWidth() * m_bitmap->PixelHeight() * m_bitmap->GetBytesPerPixel(), m_bitmap->GetBits() );
m_viewBitmap.GetBitmap( &bm );
memDC.SelectObject( &m_viewBitmap );
dc.BitBlt(pt.x, pt.y, m_bitmap->PixelWidth(), m_bitmap->PixelHeight(), &memDC, 0,0, SRCCOPY);