Page 1 of 1

New SDK drawing frame to a picturebox->Image VC++ .net

Posted: Tue Nov 16, 2010 10:26 am
by avelazquez
I am having a difficult time setting up video with the new SDK, I was used to calling the DrawFrame command on the old SDK. I am trying to send the frame to a picturebox in vc++ .net (not that familiar with MFC)

I am trying two different was with no success:

char imageBuffer[640*480];



frame->Rasterize(640,480,640,8,imageBuffer);
System::IO::MemoryStream^ ms = gcnew System::IO::MemoryStream((int)imageBuffer);
System::Drawing::Bitmap::Image^ returnImage=System::Drawing::Image::FromStream(ms);
this->pictureBox1->Image=returnImage;



AND


CBitmap bitmap;
CameraLibrary::Bitmap * scratchpad = new CameraLibrary::Bitmap(680, 480, 1, CameraLibrary::Bitmap::EightBit,0);


frame->Rasterize(scratchpad);


bitmap.CreateBitmap(640,480,1,1,((const void*)scratchpad->Bitmap::GetBits()));
System::Drawing::Bitmap^ IMAGE=System::Drawing::Bitmap::FromHbitmap(System::IntPtr(bitmap));
pictureBox1->Image =dynamic_cast(IMAGE);


ANY HELP IS GREATLY APPRECIATED!

Re: New SDK drawing frame to a picturebox->Image VC++ .net

Posted: Tue Nov 16, 2010 3:58 pm
by VincentG
answered via email

Re: New SDK drawing frame to a picturebox->Image VC++ .net

Posted: Mon Nov 22, 2010 7:35 am
by mikeincinci
I too would be interested in this function. Please share with the rest of us.
Thanks,
Mike

Re: New SDK drawing frame to a picturebox->Image VC++ .net

Posted: Mon Nov 22, 2010 4:06 pm
by VincentG
If you leave the final parameter zero, the Bitmap will allocate the buffer itself--so what you're doing is correct. If you wanted to allocate the memory for the bitmap, you could pass a pointer to that memory in that parameter, but the easiest way is to let the Bitmap take care of it for you.