]> Creatis software - gdcm.git/commitdiff
Port Mathieu's modif for writting JPEG2000
authorjpr <jpr>
Thu, 6 Jul 2006 12:38:05 +0000 (12:38 +0000)
committerjpr <jpr>
Thu, 6 Jul 2006 12:38:05 +0000 (12:38 +0000)
src/gdcmCommon.h
src/gdcmDocEntry.cxx
src/gdcmDocument.cxx
src/gdcmFileHelper.cxx
src/gdcmFileHelper.h

index 98eee44ad8f308c730311ff168e9a89668f1a733..208203771e264d06ba18cb0c5e8ac3fecb921f21 100644 (file)
@@ -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)
index dac8355c49667d19ac514493952b464d29a35eaa..4391cd064a62c6ca6064f94e21c294c6b8ebb970 100644 (file)
@@ -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);
index fbc717435e6030132b576b6619da0410fc71ded7..29fe967db0bc60fb16116434164cb954f11432f4 100644 (file)
@@ -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];
index 71fb4d22037c765ff5aa22d518f145ca1fdc03af..c95a07cc5c8e01f03eeea8410cc42562a70174ec 100644 (file)
@@ -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'
  */ 
index 278e2f7d2cf9cff7279e8b29ccd755ed21c87e08..34b0c7a3c2bd7faed535ff276bb138f68cdb0226 100644 (file)
@@ -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();