47 void IRImage::fillRaw (
unsigned width,
unsigned height,
unsigned short* ir_buffer,
unsigned line_step)
const throw (
OpenNIException)
49 if (width > ir_md_->XRes () || height > ir_md_->YRes ())
50 THROW_OPENNI_EXCEPTION (
"upsampling not supported: %d x %d -> %d x %d", ir_md_->XRes (), ir_md_->YRes (), width, height);
52 if (ir_md_->XRes () % width != 0 || ir_md_->YRes () % height != 0)
53 THROW_OPENNI_EXCEPTION (
"downsampling only supported for integer scale: %d x %d -> %d x %d", ir_md_->XRes (), ir_md_->YRes (), width, height);
56 line_step = width *
sizeof (
unsigned short);
59 if (width == ir_md_->XRes () && height == ir_md_->YRes () && (line_step == width *
sizeof (
unsigned short)))
61 memcpy (ir_buffer, ir_md_->WritableData(), ir_md_->DataSize ());
66 unsigned bufferSkip = line_step - width *
sizeof (
unsigned short);
69 unsigned xStep = ir_md_->XRes () / width;
70 unsigned ySkip = (ir_md_->YRes () / height - 1) * ir_md_->XRes ();
74 for (
unsigned yIdx = 0; yIdx < height; ++yIdx, irIdx += ySkip)
76 for (
unsigned xIdx = 0; xIdx < width; ++xIdx, irIdx += xStep, ++ir_buffer)
77 *ir_buffer = (
unsigned short) (ir_md_->WritableData()[irIdx]);
82 char* cBuffer =
reinterpret_cast<char*
> (ir_buffer);
83 ir_buffer =
reinterpret_cast<unsigned short*
> (cBuffer + bufferSkip);
#define THROW_OPENNI_EXCEPTION(format,...)