-/**
- * \brief Read from file a 12 bits per pixel image and uncompress it
- * into a 16 bits per pixel image.
- */
-void gdcmFile::ConvertDecompress12BitsTo16Bits(
- uint8_t* pixelZone,
- int sizeX,
- int sizeY,
- FILE* filePtr)
- throw ( gdcmFormatError )
-{
- int nbPixels = sizeX * sizeY;
- uint16_t* destination = (uint16_t*)pixelZone;
-
- for( int p = 0; p < nbPixels; p += 2 )
- {
- uint8_t b0, b1, b2;
- size_t ItemRead;
-
- ItemRead = fread( &b0, 1, 1, filePtr);
- if ( ItemRead != 1 )
- {
- throw gdcmFormatError( "gdcmFile::ConvertDecompress12BitsTo16Bits()",
- "Unfound first block" );
- }
-
- ItemRead = fread( &b1, 1, 1, filePtr);
- if ( ItemRead != 1 )
- {
- throw gdcmFormatError( "gdcmFile::ConvertDecompress12BitsTo16Bits()",
- "Unfound second block" );
- }
-
- ItemRead = fread( &b2, 1, 1, filePtr);
- if ( ItemRead != 1 )
- {
- throw gdcmFormatError( "gdcmFile::ConvertDecompress12BitsTo16Bits()",
- "Unfound second block" );
- }
-
- // Two steps are necessary to please VC++
- //
- // 2 pixels 12bit = [0xABCDEF]
- // 2 pixels 16bit = [0x0ABD] + [0x0FCE]
- // A B D
- *destination++ = ((b0 >> 4) << 8) + ((b0 & 0x0f) << 4) + (b1 & 0x0f);
- // F C E
- *destination++ = ((b2 & 0x0f) << 8) + ((b1 >> 4) << 4) + (b2 >> 4);
-
- /// \todo JPR Troubles expected on Big-Endian processors ?
- }
-}
-//-----------------------------------------------------------------------------