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

Post Reply
avelazquez
Posts: 19
Joined: Mon Jun 07, 2010 7:40 am

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

Post 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!
VincentG
Posts: 7728
Joined: Mon Jul 17, 2006 5:00 am
Location: Corvallis, Oregon

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

Post by VincentG »

answered via email
mikeincinci
Posts: 22
Joined: Tue Aug 14, 2007 7:26 am

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

Post by mikeincinci »

I too would be interested in this function. Please share with the rest of us.
Thanks,
Mike
VincentG
Posts: 7728
Joined: Mon Jul 17, 2006 5:00 am
Location: Corvallis, Oregon

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

Post 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.
Post Reply