X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmPixelReadConvert.cxx;h=bb8d4e7f4fe83e06f6c5e95a2b0cd860c15360c8;hb=ba355c8e668e9da685de102607f7001aa8504d7d;hp=fc73af9c4fd1ee2106ffdd3108c5407fd235f659;hpb=c2fe0ed8d6bb6249a6ee4c36e4c3eef86ea80535;p=gdcm.git diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index fc73af9c..bb8d4e7f 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/10/20 09:17:54 $ - Version: $Revision: 1.82 $ + Date: $Date: 2005/11/08 16:35:54 $ + Version: $Revision: 1.97 $ 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, void *image_buffer, 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); //----------------------------------------------------------------------------- @@ -114,24 +114,53 @@ void PixelReadConvert::GrabInformationsFromFile( File *file ) //PixelSize = file->GetPixelSize(); Useless PixelSign = file->IsSignedPixelData(); SwapCode = file->GetSwapCode(); - std::string ts = file->GetTransferSyntax(); - IsRaw = - ( ! file->IsDicomV3() ) - || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRLittleEndian - || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRBigEndianPrivateGE - || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRLittleEndian - || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian - || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::DeflatedExplicitVRLittleEndian; - - IsPrivateGETransferSyntax = + + if (! file->IsDicomV3() ) // Should be ACR-NEMA file + { + IsRaw = true; + // Don't loose time checking unexistant Transfer Syntax ! + IsPrivateGETransferSyntax = IsMPEG + = IsJPEG2000 = IsJPEGLS = IsJPEGLossy + = IsJPEGLossless = IsRLELossless + = false; + } + else + { + std::string ts = file->GetTransferSyntax(); + + IsRaw = false; + while (true) + { + // mind the order : check the most usual first. + if( IsRaw = Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRLittleEndian) break; + if( IsRaw = Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRLittleEndian ) break; + if( IsRaw = Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian) break; + if( IsRaw = Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRBigEndianPrivateGE) break; + if( IsRaw = Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::DeflatedExplicitVRLittleEndian) break; + break; + } + + IsPrivateGETransferSyntax = ( Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRBigEndianPrivateGE ); - IsMPEG = Global::GetTS()->IsMPEG(ts); - IsJPEG2000 = Global::GetTS()->IsJPEG2000(ts); - IsJPEGLS = Global::GetTS()->IsJPEGLS(ts); - IsJPEGLossy = Global::GetTS()->IsJPEGLossy(ts); - IsJPEGLossless = Global::GetTS()->IsJPEGLossless(ts); - IsRLELossless = Global::GetTS()->IsRLELossless(ts); + IsMPEG = IsJPEG2000 = IsJPEGLS = IsJPEGLossy = IsJPEGLossless = IsRLELossless = false; + + if (!IsRaw) + { + while(true) + { + // mind the order : check the most usual first. + if( IsJPEGLossy = Global::GetTS()->IsJPEGLossy(ts) ) break; + if( IsJPEGLossless = Global::GetTS()->IsJPEGLossless(ts) ) break; + if( IsRLELossless = Global::GetTS()->IsRLELossless(ts) ) break; + 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 << "]"); + break; + } + } + } PixelOffset = file->GetPixelOffset(); PixelDataLength = file->GetPixelAreaLength(); @@ -155,7 +184,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file ) LutGreenDescriptor = file->GetEntryString( 0x0028, 0x1102 ); LutBlueDescriptor = file->GetEntryString( 0x0028, 0x1103 ); - // The following comment is probabely meaningless, since LUT are *always* + // FIXME : The following comment is probabely meaningless, since LUT are *always* // loaded at parsing time, whatever their length is. // Depending on the value of Document::MAX_SIZE_LOAD_ELEMENT_VALUE @@ -272,7 +301,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, Raw, PixelDataLength); + ReadMPEGFile(fp, (char*)Raw, PixelDataLength); return true; } else @@ -526,17 +555,19 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp ) } /** - * \brief Build Red/Green/Blue/Alpha LUT from File - * when (0028,0004),Photometric Interpretation = [PALETTE COLOR ] - * and (0028,1101),(0028,1102),(0028,1102) - * - xxx Palette Color Lookup Table Descriptor - are found - * and (0028,1201),(0028,1202),(0028,1202) - * - xxx Palette Color Lookup Table Data - are found + * \brief Build Red/Green/Blue/Alpha LUT from File when : + * - (0028,0004) : Photometric Interpretation == [PALETTE COLOR ] + * and + * - (0028,1101),(0028,1102),(0028,1102) + * xxx Palette Color Lookup Table Descriptor are found + * and + * - (0028,1201),(0028,1202),(0028,1202) + * xxx Palette Color Lookup Table Data - are found * \warning does NOT deal with : - * 0028 1100 Gray Lookup Table Descriptor (Retired) - * 0028 1221 Segmented Red Palette Color Lookup Table Data - * 0028 1222 Segmented Green Palette Color Lookup Table Data - * 0028 1223 Segmented Blue Palette Color Lookup Table Data + * - 0028 1100 Gray Lookup Table Descriptor (Retired) + * - 0028 1221 Segmented Red Palette Color Lookup Table Data + * - 0028 1222 Segmented Green Palette Color Lookup Table Data + * - 0028 1223 Segmented Blue Palette Color Lookup Table Data * no known Dicom reader deals with them :-( * @return a RGBA Lookup Table */ @@ -794,7 +825,7 @@ 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. - + if ( IsPrivateGETransferSyntax ) { // PrivateGETransferSyntax only exists for 'true' Dicom images @@ -809,6 +840,7 @@ void PixelReadConvert::ConvertSwapZone() break; } } + if ( BitsAllocated == 16 ) { uint16_t *im16 = (uint16_t*)Raw; @@ -1209,13 +1241,13 @@ void PixelReadConvert::ConvertHandleColor() // - [Planar 1] AND [Photo C] handled with ConvertYcBcRPlanesToRGBPixels() // - [Planar 2] OR [Photo D] requires LUT intervention. - gdcmWarningMacro("--> ConvertHandleColor" + gdcmDebugMacro("--> ConvertHandleColor " << "Planar Configuration " << PlanarConfiguration ); if ( ! IsRawRGB() ) { // [Planar 2] OR [Photo D]: LUT intervention done outside - gdcmWarningMacro("--> RawRGB : LUT intervention done outside"); + gdcmDebugMacro("--> RawRGB : LUT intervention done outside"); return; }