PDA

View Full Version : Snapshot in GDI+



Unregistered
February 4, 2005, 11:34:18
I store a snapshot on a GDI+ bitmap. This bitmap become invalid if I close the the input device and reopen it. The program

crash when I try to write/paint on the GDI+ bitmap.

I initialize the GdiPlus, open the device and start the video.
This is the code of the snapshot:

BITMAPINFO *BitInfo;
Bitmap *BitM;

m_pGrabber->snapImages (1,1000);
if (m_pGrabber->getLastError () != eNOERROR)
Error_and_exit

DShowLib::Grabber::tMemBufferPtr gAMB = m_pGrabber->getActiveMemBuffer ();

gAMB->lock ();

smart_ptr<BITMAPINFOHEADER> pInf = gAMB->getBitmapInfoHeader ();
BitInfo = reinterpret_cast<LPBITMAPINFO>(&*pInf);
BitM = new Bitmap (BitInfo,gAMB->getPtr ());

gAMB->unlock ();

I develop under VC6++.

I can post you the source of a simple program to test the problem.

TIA
Paolo

Stefan Geissler
February 7, 2005, 08:20:05
Hello Paolo

If the device is closed, the membuffer is deleted. I think, the memory that is used for the bitmap was the membuffer. It was not allocated new and copied. Thus i suggest to allocate memory for the image, copy the membuffer image data into this memory and create the bitmap with it.