- // we save the initial values of the following
- // in order to be able to restore the header in a disk-consistent state
- // (if user asks twice to get the pixels from disk)
-
- if ( PixelRead != -1 ) // File was "read" before
- {
- RestoreInitialValues();
- }
-
- PixelRead = 1 ; // PixelRaw
-
- if ( ImageDataSize > maxSize )
- {
- dbg.Verbose(0, "File::GetImageDataIntoVector: pixel data bigger"
- "than caller's expected MaxSize");
- return (size_t)0;
- }
-
- ReadPixelData( destination );
-
- // Number of Bits Allocated for storing a Pixel
- int numberBitsAllocated = HeaderInternal->GetBitsAllocated();
- if ( numberBitsAllocated == 0 )
- {
- numberBitsAllocated = 16;
- }
-
- // Number of Bits actually used
- int numberBitsStored = HeaderInternal->GetBitsStored();
- if ( numberBitsStored == 0 )
- {
- numberBitsStored = numberBitsAllocated;
- }
-
- // High Bit Position
- int highBitPosition = HeaderInternal->GetHighBitPosition();
- if ( highBitPosition == 0 )
- {
- highBitPosition = numberBitsAllocated - 1;
- }
-
- bool signedPixel = HeaderInternal->IsSignedPixelData();
-
- PixelConvert::ConvertReorderEndianity(
- (uint8_t*) destination,
- ImageDataSize,
- numberBitsStored,
- numberBitsAllocated,
- HeaderInternal->GetSwapCode(),
- signedPixel );
-
- PixelConvert::ConvertReArrangeBits(
- (uint8_t*) destination,
- ImageDataSize,
- numberBitsStored,
- numberBitsAllocated,
- highBitPosition );
-
-#ifdef GDCM_DEBUG
- FILE* DebugFile;
- DebugFile = fopen( "SpuriousFile.RAW", "wb" );
- fwrite( PixelConvertor.GetUncompressed(),
- PixelConvertor.GetUncompressedsSize(),
- 1, DebugFile );
- fclose( DebugFile );
-#endif //GDCM_DEBUG
-
-// SPLIT ME
-//////////////////////////////////
-// Deal with the color
-
- // Monochrome pictures don't require color intervention
- if ( HeaderInternal->IsMonochrome() )
- {
- return ImageDataSize;
- }
-
- // Planar configuration = 0 : Pixels are already RGB
- // Planar configuration = 1 : 3 planes : R, G, B
- // Planar configuration = 2 : 1 gray Plane + 3 LUT
-
- // Well ... supposed to be !
- // See US-PAL-8-10x-echo.dcm: PlanarConfiguration=0,
- // PhotometricInterpretation=PALETTE COLOR
- // and heuristic has to be found :-(
-
- int planConf = HeaderInternal->GetPlanarConfiguration();
-
- // Planar configuration = 2 ==> 1 gray Plane + 3 LUT
- // ...and...
- // whatever the Planar Configuration might be, "PALETTE COLOR "
- // implies that we deal with the palette.
- if ( ( planConf == 2 ) || HeaderInternal->IsPaletteColor() )
- {
- return ImageDataSize;
- }
-
- // When planConf is 0, pixels are allready in RGB
-
- if ( planConf == 1 )
- {
- uint8_t* newDest = new uint8_t[ImageDataSize];
- // Warning : YBR_FULL_422 acts as RGB
- if ( HeaderInternal->IsYBRFull() )
- {
- ConvertYcBcRPlanesToRGBPixels((uint8_t*)destination, newDest);
- }
- else
- {
- ConvertRGBPlanesToRGBPixels((uint8_t*)destination, newDest);
- }
- memmove(destination, newDest, ImageDataSize);
- delete[] newDest;
- }