X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFile.cxx;h=02e6a08ad5618281327011bdc88f1b7c2a48a6de;hb=40b909789581894e57a0d8f22d6f1f91f55e7f84;hp=9a9dc3ae160adce704c8b32dce1372bd05837286;hpb=eafd36f8a658f5d3b29e733bf87540150feaddf6;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 9a9dc3ae..02e6a08a 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2004/10/12 09:59:45 $ - Version: $Revision: 1.140 $ + Date: $Date: 2004/10/15 10:43:27 $ + Version: $Revision: 1.144 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -87,8 +87,9 @@ void File::Initialise() - // Just in case some access to a Header element requires disk access: - FILE* fp = HeaderInternal->OpenFile(); + // Just in case some access to a Header element requires disk access. + // Note: gdcmDocument::Fp is leaved open after OpenFile. + (void)HeaderInternal->OpenFile(); // Number of Bits Allocated for storing a Pixel is defaulted to 16 // when absent from the header. int numberBitsAllocated = HeaderInternal->GetBitsAllocated(); @@ -137,7 +138,13 @@ void File::Initialise() PixelConverter.SetPixelDataLength( HeaderInternal->GetPixelAreaLength() ); PixelConverter.SetRLEInfo( &(HeaderInternal->RLEInfo) ); PixelConverter.SetJPEGInfo( &(HeaderInternal->JPEGInfo) ); - PixelConverter.SetDecompressedSize( ImageDataSize ); + PixelConverter.SetHasLUT( HeaderInternal->HasLUT() ); + + PixelConverter.SetPlanarConfiguration( + HeaderInternal->GetPlanarConfiguration() ); + PixelConverter.SetIsMonochrome( HeaderInternal->IsMonochrome() ); + PixelConverter.SetIsPaletteColor( HeaderInternal->IsPaletteColor() ); + PixelConverter.SetIsYBRFull( HeaderInternal->IsYBRFull() ); HeaderInternal->CloseFile(); @@ -536,7 +543,7 @@ uint8_t* File::GetImageDataRaw () * @return On success, the number of bytes actually copied. Zero on * failure e.g. MaxSize is lower than necessary. */ -size_t File::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) +void File::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) { // we save the initial values of the following // in order to be able to restore the header in a disk-consistent state @@ -553,74 +560,19 @@ size_t File::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) { dbg.Verbose(0, "File::GetImageDataIntoVector: pixel data bigger" "than caller's expected MaxSize"); - return (size_t)0; + return; } FILE* fp = HeaderInternal->OpenFile(); - PixelConverter.ReadAndDecompressPixelData( destination, fp ); + PixelConverter.ReadAndDecompressPixelData( fp ); HeaderInternal->CloseFile(); - - PixelConverter.ReorderEndianity( (uint8_t*) destination ); - - PixelConverter.ReArrangeBits( (uint8_t*) destination ); - -#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 + memmove( destination, + (void*)PixelConverter.GetDecompressed(), + PixelConverter.GetDecompressedSize() ); - if ( planConf == 1 ) + if ( ! PixelConverter.IsDecompressedRGB() ) { - // Warning : YBR_FULL_422 acts as RGB - if ( HeaderInternal->IsYBRFull() ) - { - PixelConverter.ConvertYcBcRPlanesToRGBPixels( - (uint8_t*)destination, - ImageDataSize ); - } - else - { - PixelConverter.ConvertRGBPlanesToRGBPixels( - (uint8_t*)destination, - ImageDataSize ); - } - + return; } /////////////////////////////////////////////////// @@ -643,7 +595,7 @@ size_t File::GetImageDataIntoVectorRaw (void* destination, size_t maxSize) HeaderInternal->SetEntryByNumber(photInt,0x0028,0x0004); HeaderInternal->SetEntryByNumber(planConfig,0x0028,0x0006); - return ImageDataSize; + return; } /**