From b6c826571b5f85de9256b0973df29e916c40d243 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 12 Mar 2003 13:09:00 +0000 Subject: [PATCH] =?utf8?q?POur=20traiter=20certaines=20(=3F)=20images=20Ph?= =?utf8?q?ilips=20pour=20lesquelles=20le=20File=20Preamble=20est=20suivi?= =?utf8?q?=20de=20l'elem=20(0002,0001)=20et=20non=20pas=20de=20l'elem=20(0?= =?utf8?q?002,0000)=20-pas=20d'autre=20possibilit=E9=20envisageable=20...-?= =?utf8?q?=20Peut-etre?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/Makefile.am | 6 ++++-- src/gdcmHeader.cxx | 37 ++++++++++++++++++++++++++++++------- src/gdcmHeader.h | 2 ++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c5506f18..ec064d88 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,7 +26,8 @@ libgdcm_la_SOURCES= \ gdcmDictSet.cxx \ gdcmElValSet.cxx \ gdcmHeaderIdo.cxx \ - gdcmFile.cxx + gdcmFile.cxx \ + gdcmJpeg.cxx libgdcmincludedir = $(includedir) libgdcminclude_HEADERS = \ @@ -34,4 +35,5 @@ libgdcminclude_HEADERS = \ gdcm.h \ gdcmException.h \ gdcmIdo.h \ - gdcmUtil.h + gdcmUtil.h \ + iddcmjpeg.h diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 231b5bc4..37b2e1ec 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -13,6 +13,8 @@ #include "gdcmUtil.h" #include "gdcmHeader.h" +#include + // Refer to gdcmHeader::CheckSwap() #define HEADER_LENGTH_TO_READ 256 // Refer to gdcmHeader::SetMaxSizeLoadElementValue() @@ -128,8 +130,9 @@ void gdcmHeader::CheckSwap() if(filetype == TrueDicom) { // Next, determine the value representation (VR). Let's skip to the - // first element (0002, 0000) and check there if we find "UL", in - // which case we (almost) know it is explicit VR. + // first element (0002, 0000) and check there if we find "UL" + // - or "OB" if the 1st one is (0002,0001) -, + // in which case we (almost) know it is explicit VR. // WARNING: if it happens to be implicit VR then what we will read // is the length of the group. If this ascii representation of this // length happens to be "UL" then we shall believe it is explicit VR. @@ -139,10 +142,12 @@ void gdcmHeader::CheckSwap() // We need to skip : // * the 128 bytes of File Preamble (often padded with zeroes), // * the 4 bytes of "DICM" string, - // * the 4 bytes of the first tag (0002, 0000), + // * the 4 bytes of the first tag (0002, 0000),or (0002, 0001) // i.e. a total of 136 bytes. entCur = deb + 136; - if(memcmp(entCur, "UL", (size_t)2) == 0) { + if( (memcmp(entCur, "UL", (size_t)2) == 0) || + (memcmp(entCur, "OB", (size_t)2) == 0) ) + { filetype = ExplicitVR; dbg.Verbose(1, "gdcmHeader::CheckSwap:", "explicit Value Representation"); @@ -241,7 +246,11 @@ void gdcmHeader::GetPixels(size_t lgrTotale, void* _Pixels) { size_t pixelsOffset; pixelsOffset = GetPixelOffset(); fseek(fp, pixelsOffset, SEEK_SET); - fread(_Pixels, 1, lgrTotale, fp); + if (IsJPEGLossless()) { + _Pixels=_IdDcmJpegRead(fp); + } else { + fread(_Pixels, 1, lgrTotale, fp); + } } @@ -286,7 +295,7 @@ void gdcmHeader::FindVR( ElValue *ElVal) { // PostPone this test in an optional integrity check at the end // of parsing or only in debug mode. if ( RealExplicit && !dicom_vr->count(vr) ) - RealExplicit = false; + RealExplicit= false; if ( RealExplicit ) { if ( ElVal->IsVrUnknown() ) { @@ -393,7 +402,7 @@ bool gdcmHeader::IsExplicitVRBigEndianTransferSyntax(void) { return false; LoadElementValueSafe(Element); string Transfer = Element->GetValue(); - if ( Transfer == "1.2.840.10008.1.2.2" ) + if ( Transfer == "1.2.840.10008.1.2.2" ) //1.2.2 ??? A verifier ! return true; return false; } @@ -416,6 +425,20 @@ bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) { return false; } +// faire qq chose d'intelligent a la place de ça + +bool gdcmHeader::IsJPEGLossless(void) { + ElValue* Element = PubElVals.GetElementByNumber(0x0002, 0x0010); + if ( !Element ) + return false; + LoadElementValueSafe(Element); + const char * Transfert = Element->GetValue().c_str(); + if ( memcmp(Transfert+strlen(Transfert)-2 ,"70",2)==0) return true; + if ( memcmp(Transfert+strlen(Transfert)-2 ,"55",2)==0) return true; + return false; +} + + /** * \ingroup gdcmHeader * \brief Determines if the Transfer Syntax was allready encountered diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 02c58ef6..fa33ebc8 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -105,6 +105,8 @@ private: bool IsJPEGExtendedProcess2_4TransferSyntax(void); bool IsJPEGExtendedProcess3_5TransferSyntax(void); bool IsJPEGSpectralSelectionProcess6_8TransferSyntax(void); + + bool IsJPEGLossless(void); protected: // FIXME: is this enum still necessary ?? -- 2.48.1