我有一台uEye相机,每隔1000毫秒拍摄图像快照,并希望在WPF Image
控件中呈现它们,就像这样:
Bitmap MyBitmap;
// get geometry of uEye image buffer
int width = 0, height = 0, bitspp = 0, pitch = 0, bytespp = 0;
long imagesize = 0;
m_uEye.InquireImageMem(m_pCurMem, GetImageID(m_pCurMem), ref width, ref height, ref bitspp, ref pitch);
bytespp = (bitspp + 1) / 8;
imagesize = width * height * bytespp; // image size in bytes
// bulit a system bitmap
MyBitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
// fill the system bitmap with the image data from the uEye SDK buffer
BitmapData bd = MyBitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
m_uEye.CopyImageMem(m_pCurMem, GetImageID(m_pCurMem), bd.Scan0);
MyBitmap.UnlockBits(bd);
我正在尝试以每秒1次的速率将这些位图放入
Image
控件中。我该如何让Bitmap
出现在Image
控件中,并在完成后立即处理它们,以留下最小的内存占用,成为一个好的程序员 :) ?