From: jpr Date: Thu, 6 Jul 2006 12:38:05 +0000 (+0000) Subject: Port Mathieu's modif for writting JPEG2000 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=6537b093e30bffefce36d66f358c4015e773542a;p=gdcm.git Port Mathieu's modif for writting JPEG2000 --- diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index 98eee44a..20820377 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmCommon.h,v $ Language: C++ - Date: $Date: 2006/05/31 16:02:32 $ - Version: $Revision: 1.111 $ + Date: $Date: 2006/07/06 12:38:05 $ + Version: $Revision: 1.112 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -46,6 +46,12 @@ namespace gdcm { // Centralize information about the gdcm dictionary in only one file: +// +// ==> +// ==> Don't forget gdcm/gdcmPython/gdcm.i +// ==> +// + #ifndef PUB_DICT_PATH # define PUB_DICT_PATH "../Dicts/" #endif @@ -101,7 +107,8 @@ enum FileType { ACR_LIBIDO, /// \todo FIXME : an encapsulated JPEG file may be /// either ExplicitVR or ImplicitVR, right? - JPEG + JPEG, + JPEG2000 }; /// \brief type of the elements composing a DICOMDIR (for internal use only) diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index dac8355c..4391cd06 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2006/07/04 07:58:50 $ - Version: $Revision: 1.84 $ + Date: $Date: 2006/07/06 12:38:06 $ + Version: $Revision: 1.85 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -103,7 +103,7 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype) binary_write( *fp, elem); //element number // Dicom V3 group 0x0002 is *always* Explicit VR ! - if ( filetype == ExplicitVR || filetype == JPEG || group == 0x0002 ) + if ( filetype == ExplicitVR || filetype == JPEG || filetype == JPEG2000 || group == 0x0002 ) { // ----------- Writes the common part : the VR + the length @@ -139,7 +139,7 @@ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype) || (vr == "UN") || (vr == "UT") ) { binary_write(*fp, zero); - if (filetype == JPEG && GetGroup() == 0x7fe0 && GetElement() == 0x0010) + if ( (filetype == JPEG || filetype == JPEG2000) && group == 0x7fe0 && elem == 0x0010) { gdcmAssertMacro( GetVR() == "OW" ); binary_write(*fp, ffff); diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index fbc71743..29fe967d 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2006/06/21 14:06:56 $ - Version: $Revision: 1.351 $ + Date: $Date: 2006/07/06 12:38:06 $ + Version: $Revision: 1.352 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -689,7 +689,7 @@ void Document::WriteContent(std::ofstream *fp, FileType filetype) // Skip if user wants to write an ACR-NEMA file if ( filetype == ImplicitVR || filetype == ExplicitVR || - filetype == JPEG ) + filetype == JPEG || filetype == JPEG2000 ) { // writing Dicom File Preamble char filePreamble[128]; diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index 71fb4d22..c95a07cc 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -4,8 +4,8 @@ Module: $RCSfile: gdcmFileHelper.cxx,v $ Language: C++ - Date: $Date: 2006/07/04 09:51:11 $ - Version: $Revision: 1.107 $ + Date: $Date: 2006/07/06 12:38:06 $ + Version: $Revision: 1.108 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -729,8 +729,12 @@ bool FileHelper::Write(std::string const &fileName) case JPEG: SetWriteFileTypeToJPEG(); break; + + case JPEG2000: + SetWriteFileTypeToJPEG2000(); + break; } - + // -------------------------------------------------------------- // Special Patch to allow gdcm to re-write ACR-LibIDO formated images // @@ -761,7 +765,7 @@ bool FileHelper::Write(std::string const &fileName) } bool check = CheckWriteIntegrity(); // verifies length - if (WriteType == JPEG ) check = true; + if (WriteType == JPEG || WriteType == JPEG2000) check = true; if (check) { check = FileInternal->Write(fileName,WriteType); @@ -875,7 +879,7 @@ void FileHelper::SetWriteToRaw() if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files vr = "OB"; // For non RAW data. Mainly JPEG - if( WriteType == JPEG ) + if( WriteType == JPEG || WriteType == JPEG2000) { vr = "OW"; } @@ -1050,6 +1054,21 @@ void FileHelper::SetWriteFileTypeToACR() Archive->Push(0x0002,0x0102); } + /** + * \brief Sets in the File the TransferSyntax to 'JPEG2000' + */ +void FileHelper::SetWriteFileTypeToJPEG2000() +{ + std::string ts = Util::DicomString( + Global::GetTS()->GetSpecialTransferSyntax(TS::JPEG2000Lossless) ); + + DataEntry *tss = CopyDataEntry(0x0002,0x0010,"UI"); + tss->SetString(ts); + + Archive->Push(tss); + tss->Delete(); +} + /** * \brief Sets in the File the TransferSyntax to 'JPEG' */ diff --git a/src/gdcmFileHelper.h b/src/gdcmFileHelper.h index 278e2f7d..34b0c7a3 100644 --- a/src/gdcmFileHelper.h +++ b/src/gdcmFileHelper.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFileHelper.h,v $ Language: C++ - Date: $Date: 2006/05/30 08:14:50 $ - Version: $Revision: 1.45 $ + Date: $Date: 2006/07/06 12:38:06 $ + Version: $Revision: 1.46 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -137,6 +137,8 @@ public: void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); } /// \brief Tells the writer we want to write as JPEG void SetWriteTypeToJPEG() { SetWriteType(JPEG); } + /// \brief Tells the writer we want to write as JPEG2000 + void SetWriteTypeToJPEG2000() { SetWriteType(JPEG2000); } /// \brief Tells the writer which format we want to write /// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO) void SetWriteType(FileType format) { WriteType = format; } @@ -183,6 +185,7 @@ protected: void SetWriteFileTypeToACR(); void SetWriteFileTypeToJPEG(); + void SetWriteFileTypeToJPEG2000(); void SetWriteFileTypeToExplicitVR(); void SetWriteFileTypeToImplicitVR(); void RestoreWriteFileType();