카메라 메타 데이터를 비트 맵으로 복사하려고하는데 메타 데이터의 각 값이 16 비트 (또는 ushort)로 표시되면 16bpp로 표시하는 것이 현명 할 것이라고 생각했습니다. garyscale 비트 맵. 다음 I 쓴 코드 :C에서 포인터로 16bpp 주소를 올바르게 지정하는 방법
// Getting the metadata from the device
metaData = new DepthMetaData();
dataSource.GetMetaData(metaData);
// Setting up bitmap, rect and data to use pointer
Bitmap bitmap = new Bitmap(metaData.XRes, metaData.YRes, PixelFormat.Format16bppGrayScale);
Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
BitmapData data = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format16bppGrayScale);
// Pointer pointing to metadata
ushort* ptrMetaData = (ushort*)dataSource.DepthMapPtr.ToPointer();
lock(this)
{
// Runs through the whole bitmap and assigns the entry in the metadata
// to a pixel
for (int y = 0; y < bitmap.Height; ++y)
{
ushort* ptrDestination = (ushort*)data.Scan0.ToPointer() + y * data.Stride;
for (int x = 0; x < bitmap.Width; ++x, ++ptrMetaData)
{
ptrDestination[x] = (ushort)*ptrMetaData;
}
}
}
// Once done unlock the bitmap so that it can be read again
bitmap.UnlockBits(data);
하는 메타 데이터의 XRES를 실행할 때 = 640 YRes = 480 코드 ptrDestination [X] = (USHORT) "에 대한-루프에서 메모리 액세스 예외가 발생 * ptrMetaData; " 단지 240을 달리면서, 총계의 반을 달리게하고 난 후에, 선.
해상도를 줄인 위치에서 8bpp와 함께 사용 했으므로 멋지게 작동하므로 왜 여기에 없어야하는지 알 수 없습니다. 어쩌면 누군가가 그 문제를 발견 할 수도 있습니다.
덕분 이미
NB을 : 내가 대신 USHORT의 바이트를 사용하고 내가 분명히 ++ 메모장에 물건을 복사 할 수 없기 때문에 Hieght와 폭이 교환 된 픽셀 –