Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2004/10/20 14:30:40 $
- Version: $Revision: 1.146 $
+ Date: $Date: 2004/10/20 22:31:52 $
+ Version: $Revision: 1.147 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
return ImageDataSize;
}
- FILE* fp = HeaderInternal->OpenFile();
- if ( PixelConverter->BuildRGBImage( fp ) )
+ if ( PixelConverter->BuildRGBImage() )
{
memmove( destination,
(void*)PixelConverter->GetRGB(),
std::string photomInterp = "MONOCHROME1 "; // Photometric Interpretation
HeaderInternal->SetEntryByNumber(photomInterp,0x0028,0x0004);
}
- HeaderInternal->CloseFile();
/// \todo Drop Palette Color out of the Header?
return ImageDataSize;
*/
uint8_t* File::GetImageDataRaw ()
{
- size_t imgDataSize;
- if ( HeaderInternal->HasLUT() )
- /// \todo Let Header user a chance to get the right value
- imgDataSize = ImageDataSizeRaw;
- else
- imgDataSize = ImageDataSize;
-
- // FIXME (Mathieu)
- // I need to deallocate Pixel_Data before doing any allocation:
-
- if ( Pixel_Data )
- if ( LastAllocatedPixelDataLength != imgDataSize )
- free(Pixel_Data);
- if ( !Pixel_Data )
- Pixel_Data = new uint8_t[imgDataSize];
+ uint8_t* decompressed = PixelConverter->GetDecompressed();
+ if ( ! decompressed )
+ {
+ // The decompressed image migth not be loaded yet:
+ FILE* fp = HeaderInternal->OpenFile();
+ PixelConverter->ReadAndDecompressPixelData( fp );
+ HeaderInternal->CloseFile();
+ if ( ! decompressed )
+ {
+ dbg.Verbose(0, "File::GetImageDataRaw: read/decompress of "
+ "pixel data apparently went wrong.");
+ return 0;
+ }
+ }
- if ( Pixel_Data )
+// PIXELCONVERT CLEANME
+ // 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
{
- LastAllocatedPixelDataLength = imgDataSize;
-
- // we load the pixels ( grey level or RGB, but NO transformation)
- GetImageDataIntoVectorRaw(Pixel_Data, imgDataSize);
+ RestoreInitialValues();
+ }
+ if ( PixelConverter->IsDecompressedRGB() )
+ {
+ ///////////////////////////////////////////////////
+ // now, it's an RGB image
+ // Lets's write it in the Header
+ // Droping Palette Color out of the Header
+ // has been moved to the Write process.
+ // TODO : move 'values' modification to the write process
+ // : save also (in order to be able to restore)
+ // : 'high bit' -when not equal to 'bits stored' + 1
+ // : 'bits allocated', when it's equal to 12 ?!
+ std::string spp = "3"; // Samples Per Pixel
+ std::string photInt = "RGB "; // Photometric Interpretation
+ std::string planConfig = "0"; // Planar Configuration
+ HeaderInternal->SetEntryByNumber(spp,0x0028,0x0002);
+ HeaderInternal->SetEntryByNumber(photInt,0x0028,0x0004);
+ HeaderInternal->SetEntryByNumber(planConfig,0x0028,0x0006);
+ }
- // We say the value *is* loaded.
- GetHeader()->SetEntryByNumber( GDCM_BINLOADED,
- GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel());
+ // We say the value *is* loaded.
+ GetHeader()->SetEntryByNumber( GDCM_BINLOADED,
+ GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel());
+
+ // will be 7fe0, 0010 in standard cases
+ GetHeader()->SetEntryBinAreaByNumber( decompressed,
+ GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel());
- // will be 7fe0, 0010 in standard cases
- GetHeader()->SetEntryBinAreaByNumber(Pixel_Data,
- GetHeader()->GetGrPixel(), GetHeader()->GetNumPixel());
- }
PixelRead = 1; // PixelRaw
+// END PIXELCONVERT CLEANME
- return Pixel_Data;
+ return decompressed;
}
/**
Program: gdcm
Module: $RCSfile: gdcmPixelConvert.cxx,v $
Language: C++
- Date: $Date: 2004/10/20 14:30:40 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2004/10/20 22:31:52 $
+ Version: $Revision: 1.17 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* no known Dicom reader deals with them :-(
* @return a RGBA Lookup Table
*/
-void PixelConvert::BuildLUTRGBA( FILE* fp )
+void PixelConvert::BuildLUTRGBA()
{
if ( LutRGBA )
{
/**
* \brief Build the RGB image from the Decompressed imagage and the LUTs.
*/
-bool PixelConvert::BuildRGBImage( FILE* fp )
+bool PixelConvert::BuildRGBImage()
{
- BuildLUTRGBA( fp );
- if ( ! LutRGBA )
+ BuildLUTRGBA();
+ if ( ( ! LutRGBA ) || ( ! Decompressed ) )
{
return false;
}
Program: gdcm
Module: $RCSfile: gdcmPixelConvert.h,v $
Language: C++
- Date: $Date: 2004/10/20 14:30:40 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2004/10/20 22:31:52 $
+ Version: $Revision: 1.12 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void GrabInformationsFromHeader( Header* header );
bool ReadAndDecompressPixelData( FILE* fp );
void Squeeze();
- bool BuildRGBImage( FILE* fp );
+ bool BuildRGBImage();
private:
// Use the fp:
void ReadAndDecompress12BitsTo16Bits( FILE* fp ) throw ( FormatError );
bool ReadAndDecompressRLEFile( FILE* fp );
bool ReadAndDecompressJPEGFile( FILE* fp );
- void BuildLUTRGBA( FILE* fp );
// In place (within Decompressed and with no fp access) decompression
// or convertion:
+ void BuildLUTRGBA();
bool DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames );
void ConvertSwapZone();
void ConvertReorderEndianity();