C# 使用openni保存kinect图像

C# 使用openni保存kinect图像,c#,kinect,openni,bit-depth,C#,Kinect,Openni,Bit Depth,我使用openNI库中名为“SimpleViewer.net”的示例来显示带有openNI库的kinect设备的图像 现在,我的目标是保存我显示的所有图像,我认为这个地方是: lock (this) { Rectangle rect = new Rectangle(0, 0, this.bitmap.Width, this.bitmap.Height); BitmapData data = this.bitmap.LockBits(rect, ImageLockMode.Writ

我使用openNI库中名为“SimpleViewer.net”的示例来显示带有openNI库的kinect设备的图像

现在,我的目标是保存我显示的所有图像,我认为这个地方是:

lock (this)
{
    Rectangle rect = new Rectangle(0, 0, this.bitmap.Width, this.bitmap.Height);
    BitmapData data = this.bitmap.LockBits(rect, ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

    ushort* pDepth = (ushort*)this.depth.DepthMapPtr.ToPointer();

    // set pixels
    for (int y = 0; y < depthMD.YRes; ++y)
    {
        byte* pDest = (byte*)data.Scan0.ToPointer() + y * data.Stride;
        for (int x = 0; x < depthMD.XRes; ++x, ++pDepth, pDest += 3)
        {
            byte pixel = (byte)this.histogram[*pDepth];
            pDest[0] = 0;
            pDest[1] = pixel;
            pDest[2] = pixel;
        }
    }
    this.bitmap.UnlockBits(data);
}
锁定(此)
{
矩形rect=新矩形(0,0,this.bitmap.Width,this.bitmap.Height);
BitmapData data=this.bitmap.LockBits(rect、ImageLockMode.WriteOnly、System.Drawing.Imaging.PixelFormat.Format24bppRgb);
ushort*pDepth=(ushort*)this.depth.DepthMapPtr.ToPointer();
//设置像素
对于(int y=0;y
在此之前,我解锁BitmapData

我无法保存包含深度数据的bmp图像


提前感谢

您是如何保存图像的?在此之后执行此操作。Bitmap.Save()。Bitmap.Unlockbits()不起作用,引发异常…?您得到的错误是什么?我没有错误…我需要实时保存深度数据图像(每帧)。。。我使用了bitmap.Save(),但从未保存过…我没有错误