- RGBSize = DecompressedSize;
- }
-}
-
-void PixelReadConvert::GrabInformationsFromHeader( Header* header )
-{
- // Just in case some access to a Header element requires disk access.
- // Note: gdcmDocument::Fp is leaved open after OpenFile.
- std::ifstream* fp = header->OpenFile();
- // Number of Bits Allocated for storing a Pixel is defaulted to 16
- // when absent from the header.
- BitsAllocated = header->GetBitsAllocated();
- if ( BitsAllocated == 0 )
- {
- BitsAllocated = 16;
- }
-
- // Number of "Bits Stored" defaulted to number of "Bits Allocated"
- // when absent from the header.
- BitsStored = header->GetBitsStored();
- if ( BitsStored == 0 )
- {
- BitsStored = BitsAllocated;
- }
-
- // High Bit Position
- HighBitPosition = header->GetHighBitPosition();
- if ( HighBitPosition == 0 )
- {
- HighBitPosition = BitsAllocated - 1;
- }
-
- XSize = header->GetXSize();
- YSize = header->GetYSize();
- ZSize = header->GetZSize();
- SamplesPerPixel = header->GetSamplesPerPixel();
- PixelSize = header->GetPixelSize();
- PixelSign = header->IsSignedPixelData();
- SwapCode = header->GetSwapCode();
- TransferSyntaxType ts = header->GetTransferSyntax();
- IsDecompressed =
- ( ! header->IsDicomV3() )
- || ts == ImplicitVRLittleEndian
- || ts == ImplicitVRLittleEndianDLXGE
- || ts == ExplicitVRLittleEndian
- || ts == ExplicitVRBigEndian
- || ts == DeflatedExplicitVRLittleEndian;
- IsJPEG2000 = header->IsJPEG2000();
- IsJPEGLossless = header->IsJPEGLossless();
- IsRLELossless = ( ts == RLELossless );
- PixelOffset = header->GetPixelOffset();
- PixelDataLength = header->GetPixelAreaLength();
- RLEInfo = header->GetRLEInfo();
- JPEGInfo = header->GetJPEGInfo();
-
- PlanarConfiguration = header->GetPlanarConfiguration();
- IsMonochrome = header->IsMonochrome();
- IsPaletteColor = header->IsPaletteColor();
- IsYBRFull = header->IsYBRFull();
-
- /////////////////////////////////////////////////////////////////
- // LUT section:
- HasLUT = header->HasLUT();
- if ( HasLUT )
- {
- LutRedDescriptor = header->GetEntryByNumber( 0x0028, 0x1101 );
- LutGreenDescriptor = header->GetEntryByNumber( 0x0028, 0x1102 );
- LutBlueDescriptor = header->GetEntryByNumber( 0x0028, 0x1103 );
-
- // Depending on the value of Document::MAX_SIZE_LOAD_ELEMENT_VALUE
- // [ refer to invocation of Document::SetMaxSizeLoadEntry() in
- // Document::Document() ], the loading of the value (content) of a
- // [Bin|Val]Entry occurence migth have been hindered (read simply NOT
- // loaded). Hence, we first try to obtain the LUTs data from the header
- // and when this fails we read the LUTs data directely from disk.
- /// \todo Reading a [Bin|Val]Entry directly from disk is a kludge.
- /// We should NOT bypass the [Bin|Val]Entry class. Instead
- /// an access to an UNLOADED content of a [Bin|Val]Entry occurence
- /// (e.g. BinEntry::GetBinArea()) should force disk access from
- /// within the [Bin|Val]Entry class itself. The only problem
- /// is that the [Bin|Val]Entry is unaware of the FILE* is was
- /// parsed from. Fix that. FIXME.
-
- ////// Red round:
- LutRedData = (uint8_t*)header->GetEntryBinAreaByNumber( 0x0028, 0x1201 );
- if ( ! LutRedData )
- {
- // Read the Lut Data from disk
- DocEntry* lutRedDataEntry = header->GetDocEntryByNumber( 0x0028,
- 0x1201 );
- LutRedData = new uint8_t[ lutRedDataEntry->GetLength() ];
- fp->seekg( lutRedDataEntry->GetOffset() ,std::ios::beg );
- fp->read( (char*)LutRedData, (size_t)lutRedDataEntry->GetLength());
- if ( fp->fail() || fp->eof())//Fp->gcount() == 1
- {
- dbg.Verbose(0, "PixelReadConvert::GrabInformationsFromHeader: "
- "unable to read red LUT data" );
- }
- }
-
- ////// Green round:
- LutGreenData = (uint8_t*)header->GetEntryBinAreaByNumber(0x0028, 0x1202 );
- if ( ! LutGreenData)
- {
- // Read the Lut Data from disk
- DocEntry* lutGreenDataEntry = header->GetDocEntryByNumber( 0x0028,
- 0x1202 );
- LutGreenData = new uint8_t[ lutGreenDataEntry->GetLength() ];
- fp->seekg( lutGreenDataEntry->GetOffset() , std::ios::beg );
- fp->read( (char*)LutGreenData, (size_t)lutGreenDataEntry->GetLength() );
- if ( fp->fail() || fp->eof())//Fp->gcount() == 1
- {
- dbg.Verbose(0, "PixelReadConvert::GrabInformationsFromHeader: "
- "unable to read green LUT data" );
- }
- }
-
- ////// Blue round:
- LutBlueData = (uint8_t*)header->GetEntryBinAreaByNumber( 0x0028, 0x1203 );
- if ( ! LutBlueData )
- {
- // Read the Lut Data from disk
- DocEntry* lutBlueDataEntry = header->GetDocEntryByNumber( 0x0028,
- 0x1203 );
- LutBlueData = new uint8_t[ lutBlueDataEntry->GetLength() ];
- fp->seekg( lutBlueDataEntry->GetOffset() , std::ios::beg );
- fp->read( (char*)LutBlueData, (size_t)lutBlueDataEntry->GetLength() );
- if ( fp->fail() || fp->eof())//Fp->gcount() == 1
- {
- dbg.Verbose(0, "PixelReadConvert::GrabInformationsFromHeader: "
- "unable to read blue LUT data" );
- }
- }
- }
-
- ComputeDecompressedAndRGBSizes();
-
- if(fp)
- {
- header->CloseFile();