110,534
社区成员
发帖
与我相关
我的任务
分享
GCHandle hObject = GCHandle.Alloc(data, GCHandleType.Pinned);
IntPtr pObject = hObject.AddrOfPinnedObject();
if (hObject.IsAllocated)
hObject.Free();
BitmapData bmpData = new BitmapData();
bmpData.Height = video.bitmapInfo.bmiHeader.biHeight;
bmpData.Width = video.bitmapInfo.bmiHeader.biWidth;
bmpData.Scan0 = pObject;
bmpData.PixelFormat = PixelFormat.Format24bppRgb;
bmpData.Stride = data.Length / bmpData.Height ;
System.Runtime.InteropServices.Marshal.Copy(data, 0, pObject, data.Length);
Bitmap newBitmap = new Bitmap(bmpData.Width, bmpData.Height, bmpData.Stride, bmpData.PixelFormat, bmpData.Scan0);
pictureBox1.Image = newBitmap;
bitmapInfo.bmiHeader = new VideoAPI.BITMAPINFOHEADER();
bitmapInfo.bmiHeader.biSize = VideoAPI.SizeOf(bitmapInfo.bmiHeader);
bitmapInfo.bmiHeader.biWidth = mWidth;
bitmapInfo.bmiHeader.biHeight = mHeight;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biBitCount = 24;