Logo Search packages:      
Sourcecode: gdcm version File versions  Download package

bool gdcm::Unpacker12Bits::Unpack ( char *  out,
const char *  in,
size_t  n 
) [static]

Unpack an array of 'packed' 12bits data into a more conventional 16bits array n is the length in bytes of array in, out will be a 16bits array of size n / 3 * 2

Definition at line 20 of file gdcmUnpacker12Bits.cxx.

Referenced by gdcm::RAWCodec::Decode().

{
  if( n % 3 ) return false; // 3bytes are actually 2 words
  // http://groups.google.com/group/comp.lang.c/msg/572bc9b085c717f3
  short *q = (short*)out;
  const unsigned char *p = (unsigned char*)in;
  const unsigned char *end = p+n;
  unsigned char b0,b1,b2;

  while (p!=end)
    {
    b0 = *p++;
    b1 = *p++;
    b2 = *p++;
    *q++ = ((b1 & 0xf) << 8) + b0;
    *q++ = (b1>>4) + (b2<<4);
    } 
  return true;
}


Generated by  Doxygen 1.6.0   Back to index