PDA

View Full Version : MV Image Grabber



jmalberdi
June 20, 2011, 12:34:00
Hello, I'm testing MV Development Kit and I've a little problem.

I want to capture to memory an image with the MV Image Grabber filter.
First of all I've checked the box on the filter, then I catch the MV_IMAGE_CAPTURE_END_EVENT and I can write this code:

case MV_IMAGE_CAPTURE_END_EVENT:
{
Array miImagenEnArray;
int width, height, bpp;
m_ImageInfo.GetCurrentBitmapVB(out miImagenEnArray, out width, out height, out bpp);
}
break;

That's fine! but I've seen that the array length is strange.
It would be eight time more, and I can't load the image using Image.FromStream(...)

What can I do to use this Array in my program?

Thanks for your attention.

jmalberdi
June 21, 2011, 15:49:36
I could convert to file with this code:

byte[] myImageByte = (byte[])myImageArray;
Bitmap miBitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
BitmapData miBmpData = miBitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
Marshal.Copy(myImageByte, 0, miBmpData.Scan0, myImageByte.Length);
miBitmap.UnlockBits(miBmpData);
miBitmap.Save("D:\\Fotito.bmp");