|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Research.Kinect.Nui;
namespace JK.KinectExperiments.ImageStreamTest
{
public class PlanarImageHelper
{
private PlanarImage _img;
public PlanarImage Image { get { return _img; } }
public PlanarImageHelper(PlanarImage src)
{
_img = src;
}
public Byte GetRedAt(int x, int y)
{
return _img.Bits[y * _img.Width * _img.BytesPerPixel + x * _img.BytesPerPixel + 2];
}
public Byte GetGreenAt(int x, int y)
{
return _img.Bits[y * _img.Width * _img.BytesPerPixel + x * _img.BytesPerPixel + 1];
}
public Byte GetBlueAt(int x, int y)
{
return _img.Bits[y * _img.Width * _img.BytesPerPixel + x * _img.BytesPerPixel + 0];
}
public int GetPlayerAt(int x, int y)
{
return _img.Bits[y * _img.Width * _img.BytesPerPixel + x * _img.BytesPerPixel] & 0x07;
}
public int GetDepthAt(int x, int y, bool hasPlayerData)
{
try
{
int BaseByte = y * _img.Width * _img.BytesPerPixel + x * _img.BytesPerPixel;
if (hasPlayerData)
{
return (_img.Bits[BaseByte + 1] << 5) | (_img.Bits[BaseByte] >> 3);
}
else
{
return (_img.Bits[BaseByte + 1] << 8) | (_img.Bits[BaseByte]);
}
}
catch
{
return 0;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Programming since 10 years old with first commercial app sold in age of 16.
In past got Bachelor's degree in Computer Sciences and worked as Linux administrator and software developer.
Currently slightly over 30 and working as IT Project Manager for Flextronics.
Still coding for fun and/or money.