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

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

Pack an array of 16bits where all values are 12bits into a pack form n is the length in bytes of array in, out will be a fake 8bits array of size n / 2 * 3

Definition at line 40 of file gdcmUnpacker12Bits.cxx.

{
  if( n % 4 ) return false; // we need an even number of 'words' so that 2 words are split in 3 bytes
  unsigned char *q = (unsigned char*)out;
  const unsigned short *p = (unsigned short*)in;
  const unsigned short *end = (unsigned short*)(in+n);
  unsigned short b0,b1;

  while(p!=end)
    {
    b0 = *p++;
    b1 = *p++;

    *q++ = (b0 & 0xff);
    *q++ = (b0 >> 8) + ((b1 & 0xf) << 4);
    *q++ = b1 >> 4;
    }
  return false;
}


Generated by  Doxygen 1.6.0   Back to index