X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmPixelReadConvert.cxx;h=38df35665ce194ed14117d4541c5bd5e34ad8ac8;hb=6d79b5e185867ef00629f1ccb279c32daa6357d2;hp=67431bfc6858b620d4e3d7f9df49d4ee8f4e241b;hpb=e9a711266d34e33b482edbe241b2e40db7d9915a;p=gdcm.git diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 67431bfc..38df3566 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2005/11/09 10:18:44 $ - Version: $Revision: 1.98 $ + Date: $Date: 2005/11/28 16:50:32 $ + Version: $Revision: 1.105 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -31,7 +31,7 @@ namespace gdcm { -bool ReadMPEGFile (std::ifstream *fp, char *inputdata, size_t lenght); +//bool ReadMPEGFile (std::ifstream *fp, char *inputdata, size_t lenght); bool gdcm_read_JPEG2000_file (void* raw, char *inputdata, size_t inputlength); //----------------------------------------------------------------------------- @@ -115,21 +115,21 @@ void PixelReadConvert::GrabInformationsFromFile( File *file ) PixelSign = file->IsSignedPixelData(); SwapCode = file->GetSwapCode(); - if (! file->IsDicomV3() ) // Should be ACR-NEMA file - { - IsRaw = true; - // Don't loose time checking unexistant Transfer Syntax ! - IsPrivateGETransferSyntax = IsMPEG + IsPrivateGETransferSyntax = IsMPEG = IsJPEG2000 = IsJPEGLS = IsJPEGLossy = IsJPEGLossless = IsRLELossless = false; + + if (! file->IsDicomV3() ) // Should be ACR-NEMA file + { + IsRaw = true; } else { std::string ts = file->GetTransferSyntax(); IsRaw = false; - while (true) + while (true) // short to write than if elseif elseif elseif ... { // mind the order : check the most usual first. if( IsRaw = Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRLittleEndian) break; @@ -139,12 +139,13 @@ void PixelReadConvert::GrabInformationsFromFile( File *file ) if( IsRaw = Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::DeflatedExplicitVRLittleEndian) break; break; } - + // cache whether this is a strange GE transfer syntax (which uses + // a little endian transfer syntax for the header and a big endian + // transfer syntax for the pixel data). IsPrivateGETransferSyntax = ( Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRBigEndianPrivateGE ); IsMPEG = IsJPEG2000 = IsJPEGLS = IsJPEGLossy = IsJPEGLossless = IsRLELossless = false; - if (!IsRaw) { while(true) @@ -156,7 +157,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file ) if( IsJPEG2000 = Global::GetTS()->IsJPEG2000(ts) ) break; if( IsMPEG = Global::GetTS()->IsMPEG(ts) ) break; if( IsJPEGLS = Global::GetTS()->IsJPEGLS(ts) ) break; - gdcmWarningMacro("Unexepected Transfer Syntax :[" << ts << "]"); + gdcmWarningMacro("Unexpected Transfer Syntax :[" << ts << "]"); break; } } @@ -270,7 +271,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) if ( PixelDataLength != RawSize ) { gdcmWarningMacro( "Mismatch between PixelReadConvert : " - << PixelDataLength << " and RawSize : " << RawSize ); + << PixelDataLength << " and RawSize : " << RawSize ); } if ( PixelDataLength > RawSize ) { @@ -301,7 +302,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) //gdcmWarningMacro( "Sorry, MPEG not yet taken into account" ); //return false; // fp has already been seek to start of mpeg - ReadMPEGFile(fp, (char*)Raw, PixelDataLength); + //ReadMPEGFile(fp, (char*)Raw, PixelDataLength); return true; } else @@ -310,7 +311,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) if ( ! ReadAndDecompressJPEGFile( fp ) ) { gdcmWarningMacro( "JPEG decompressor ( ReadAndDecompressJPEGFile()" - << " method ) failed." ); + << " method ) failed." ); return false; } } @@ -367,7 +368,7 @@ bool PixelReadConvert::BuildRGBImage() return false; } - gdcmWarningMacro( "--> BuildRGBImage" ); + gdcmDebugMacro( "--> BuildRGBImage" ); // Build RGB Pixels AllocateRGB(); @@ -638,12 +639,12 @@ void PixelReadConvert::BuildLUTRGBA() gdcmWarningMacro( "Wrong Blue LUT descriptor" ); } - gdcmWarningMacro(" lengthR " << lengthR << " debR " - << debR << " nbitsR " << nbitsR); - gdcmWarningMacro(" lengthG " << lengthG << " debG " - << debG << " nbitsG " << nbitsG); - gdcmWarningMacro(" lengthB " << lengthB << " debB " - << debB << " nbitsB " << nbitsB); + gdcmDebugMacro(" lengthR " << lengthR << " debR " + << debR << " nbitsR " << nbitsR); + gdcmDebugMacro(" lengthG " << lengthG << " debG " + << debG << " nbitsG " << nbitsG); + gdcmDebugMacro(" lengthB " << lengthB << " debB " + << debB << " nbitsB " << nbitsB); if ( !lengthR ) // if = 2^16, this shall be 0 see : CP-143 lengthR=65536; @@ -799,7 +800,6 @@ void PixelReadConvert::BuildLUTRGBA() void PixelReadConvert::ConvertSwapZone() { unsigned int i; - uint16_t localSwapCode = SwapCode; // If this file is 'ImplicitVR BigEndian PrivateGE Transfer Syntax', // then the header is in little endian format and the pixel data is in @@ -827,26 +827,27 @@ void PixelReadConvert::ConvertSwapZone() // Therefore, in either case, if the file is in // 'ImplicitVR BigEndian PrivateGE Transfer Syntax', then GDCM needs to switch // the byte swapping code when entering the pixel data. - + + int tempSwapCode = SwapCode; if ( IsPrivateGETransferSyntax ) { + gdcmWarningMacro(" IsPrivateGETransferSyntax found; turn the SwapCode"); // PrivateGETransferSyntax only exists for 'true' Dicom images // we assume there is no 'exotic' 32 bits endianess! - switch (localSwapCode) + if (SwapCode == 1234) { - case 1234: - localSwapCode = 4321; - break; - case 4321: - localSwapCode = 1234; - break; - } + tempSwapCode = 4321; + } + else if (SwapCode == 4321) + { + tempSwapCode = 1234; + } } - + if ( BitsAllocated == 16 ) { uint16_t *im16 = (uint16_t*)Raw; - switch( localSwapCode ) + switch( tempSwapCode ) { case 1234: break; @@ -859,7 +860,8 @@ void PixelReadConvert::ConvertSwapZone() } break; default: - gdcmWarningMacro("SwapCode value (16 bits) not allowed."); + gdcmWarningMacro("SwapCode value (16 bits) not allowed." + << tempSwapCode); } } else if ( BitsAllocated == 32 ) @@ -868,7 +870,7 @@ void PixelReadConvert::ConvertSwapZone() uint16_t high; uint16_t low; uint32_t *im32 = (uint32_t*)Raw; - switch ( localSwapCode ) + switch ( tempSwapCode ) { case 1234: break; @@ -904,7 +906,7 @@ void PixelReadConvert::ConvertSwapZone() } break; default: - gdcmWarningMacro("SwapCode value (32 bits) not allowed." ); + gdcmWarningMacro("SwapCode value (32 bits) not allowed." << tempSwapCode ); } } } @@ -1244,7 +1246,7 @@ void PixelReadConvert::ConvertHandleColor() // - [Planar 2] OR [Photo D] requires LUT intervention. gdcmDebugMacro("--> ConvertHandleColor " - << "Planar Configuration " << PlanarConfiguration ); + << "Planar Configuration " << PlanarConfiguration ); if ( ! IsRawRGB() ) {