public PixelBox GetSubVolume( BasicBox def )
{
if ( Compressed( format ) )
{
if ( def.Left == left && def.Top == top && def.Front == front &&
def.Right == right && def.Bottom == bottom && def.Back == back )
// Entire buffer is being queried
return this;
throw new Exception( "Cannot return subvolume of compressed PixelBuffer, in PixelBox.GetSubVolume" );
}
if ( !Contains( def ) )
throw new Exception( "Bounds out of range, in PixelBox.GetSubVolume" );
int elemSize = PixelUtil.GetNumElemBytes( format );
// Calculate new data origin
PixelBox rval = new PixelBox( def, format, data );
rval.offset = ( ( ( def.Left - left ) * elemSize ) +
( ( def.Top - top ) * rowPitch * elemSize ) +
( ( def.Front - front ) * slicePitch * elemSize ) );
rval.rowPitch = rowPitch;
rval.slicePitch = slicePitch;
rval.format = format;
return rval;
}