Skip to content

Instantly share code, notes, and snippets.

@non117
Created December 13, 2014 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save non117/54b128d930b1e554b956 to your computer and use it in GitHub Desktop.
Save non117/54b128d930b1e554b956 to your computer and use it in GitHub Desktop.
for (int y = 0; y < depthHeight; ++y)
{
for (int x = 0; x < depthWidth; ++x)
{
int depthIndex = (y * depthWidth) + x;
byte player = bodyIndexBuffer[depthIndex];
if (player != 0xff)
{
ushort depth = depthBuffer[depthIndex];
ColorSpacePoint colorPoint = this.coordinateMapper.MapDepthPointToColorSpace(x, y, depth);
// 値のチェックをここですべき
CameraSpacePoint worldPoint = this.coordinateMapper.MapDepthPointToCameraSpace(x, y, depth);
int colorX = (int)Math.Floor(colorPoint.X + 0.5);
int colorY = (int)Math.Floor(colorPoint.Y + 0.5);
// 境界値チェックすべき
int colorIndex = ((colorY * colorSize.Width) + colorX) * bytesPerPixel; // チャンネル数
byte r = colorPixels[colorIndex + redOffset]
// ....
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment