]> Creatis software - gdcm.git/commitdiff
- Add empty nutshell for JPEG-LS
authorjpr <jpr>
Mon, 24 Jan 2005 16:03:58 +0000 (16:03 +0000)
committerjpr <jpr>
Mon, 24 Jan 2005 16:03:58 +0000 (16:03 +0000)
 - Now Fragments info is get from the file, even for JPEG2000 and JPEG-LS

src/gdcmJPEGFragment.cxx
src/gdcmJpegLS.cxx [new file with mode: 0644]
src/gdcmPixelReadConvert.cxx

index ab7c1695b62a21d54e9180eec3bdca7ad93780fb..8bbe8f664b4934dd473af9e1b5f4afb2852c7d4a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJPEGFragment.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 14:52:50 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2005/01/24 16:03:58 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,8 +23,13 @@ namespace gdcm
 {
 
 // For JPEG 2000, body in file gdcmJpeg2000.cxx
+// Not yet made
 bool gdcm_read_JPEG2000_file (std::ifstream* fp, void* image_buffer);
 
+// For JPEG-LS, body in file gdcmJpegLS.cxx
+// Not yet made
+bool gdcm_read_JPEGLS_file (std::ifstream* fp, void* image_buffer);
+
 // For JPEG 8 Bits, body in file gdcmJpeg8.cxx
 //bool gdcm_read_JPEG_file8 (JPEGFragment *frag, std::ifstream *fp, void *image_buffer);
 bool gdcm_read_JPEG_memory8    (const JOCTET *buffer, const size_t buflen, 
@@ -78,7 +83,9 @@ void JPEGFragment::Print( std::ostream &os, std::string indent )
  * @param buffer     output (data decompress)
  * @param nBits      8/12 or 16 bits jpeg
  */
-void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int & statesuspension)
+void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp,
+                                                uint8_t *buffer, int nBits, 
+                                                int & statesuspension)
 {
    // First thing need to reset file to proper position:
    fp->seekg( Offset, std::ios::beg);
@@ -110,6 +117,9 @@ void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buff
    }
    else
    {
+      // FIXME : only the bits number is checked,
+      //         NOT the compression method
+
       // other JPEG lossy not supported
       gdcmErrorMacro( "Unknown jpeg lossy compression ");
       //return false;
@@ -117,7 +127,8 @@ void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buff
 
 }
 
-void JPEGFragment::DecompressJPEGSingleFrameFragmentsFromFile(JOCTET *buffer, size_t totalLength, uint8_t* raw, int nBits)
+void JPEGFragment::DecompressJPEGSingleFrameFragmentsFromFile(JOCTET *buffer,
+                                 size_t totalLength, uint8_t *raw, int nBits)
 {
    size_t howManyRead = 0;
    size_t howManyWritten = 0;
@@ -155,6 +166,9 @@ void JPEGFragment::DecompressJPEGSingleFrameFragmentsFromFile(JOCTET *buffer, si
    }
    else
    {
+      // FIXME : only the bits number is checked,
+      //         NOT the compression method
+
       // other JPEG lossy not supported
       gdcmErrorMacro( "Unsupported jpeg lossy compression ");
       delete [] buffer;
@@ -163,7 +177,9 @@ void JPEGFragment::DecompressJPEGSingleFrameFragmentsFromFile(JOCTET *buffer, si
 
 }
 
-void JPEGFragment::DecompressJPEGFragmentedFramesFromFile(JOCTET *buffer, uint8_t* raw, int nBits, size_t &howManyRead, size_t &howManyWritten, size_t totalLength)
+void JPEGFragment::DecompressJPEGFragmentedFramesFromFile(JOCTET *buffer, 
+                    uint8_t* raw, int nBits, size_t &howManyRead, 
+                    size_t &howManyWritten, size_t totalLength)
 {
    if ( nBits == 8 )
    {
@@ -202,6 +218,9 @@ void JPEGFragment::DecompressJPEGFragmentedFramesFromFile(JOCTET *buffer, uint8_
    }
    else
    {
+      // FIXME : only the bits number is checked,
+      //         NOT the compression method
+
       // other JPEG lossy not supported
       gdcmErrorMacro( "Unsupported jpeg lossy compression ");
       //delete [] buffer;
diff --git a/src/gdcmJpegLS.cxx b/src/gdcmJpegLS.cxx
new file mode 100644 (file)
index 0000000..e0094b2
--- /dev/null
@@ -0,0 +1,46 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmJpegLS.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/01/24 16:03:58 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+//-----------------------------------------------------------------------------
+#include "gdcmFileHelper.h"
+
+#include <iostream>
+#include <fstream>
+
+namespace gdcm 
+{
+
+//-----------------------------------------------------------------------------
+ /**
+ * \brief   routine for JPEG decompression 
+ * @param fp pointer to an already open file descriptor 
+ *                      JPEG-LS encoded image
+ * @param image_buffer to receive uncompressed pixels
+ * @return 1 on success, 0 on error
+ * @warning : not yet made
+ */
+
+bool gdcm_read_JPEGLS_file (std::ifstream* fp,void* image_buffer) {
+   (void)fp;                  //FIXME
+   (void)image_buffer;        //FIXME
+   std::cout << "Sorry JPEG-LS File not yet taken into account" << std::endl;
+   return false;
+}
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+
index eae74e04799277147aa3d9ebbdefbb46a32fefb8..83db9d6beeb1f1e6e318ae386df1660f20b12fc6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelReadConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 14:52:50 $
-  Version:   $Revision: 1.33 $
+  Date:      $Date: 2005/01/24 16:03:58 $
+  Version:   $Revision: 1.34 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -497,11 +497,31 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp )
 {
    if ( IsJPEG2000 )
    {
+      gdcmVerboseMacro( "Sorry, JPEG2000 not yet taken into account" );
       fp->seekg( (*JPEGInfo->Fragments.begin())->Offset, std::ios::beg);
-//      if ( ! gdcm_read_JPEG2000_file( fp,Raw ) )
+//    if ( ! gdcm_read_JPEG2000_file( fp,Raw ) )
+          gdcmVerboseMacro( "Wrong Blue LUT descriptor" );
+          return false;
+   }
+
+   if ( IsJPEGLS )
+   {
+      gdcmVerboseMacro( "Sorry, JPEG-LS not yet taken into account" );
+      fp->seekg( (*JPEGInfo->Fragments.begin())->Offset, std::ios::beg);
+//    if ( ! gdcm_read_JPEGLS_file( fp,Raw ) )
          return false;
    }
 
+   if ( ( ZSize == 1 ) && ( JPEGInfo->Fragments.size() > 1 ) )
+   {
+      // we have one frame split into several fragments
+      // we will pack those fragments into a single buffer and 
+      // read from it
+      return ReadAndDecompressJPEGSingleFrameFragmentsFromFile( fp );
+   }
+   else if (JPEGInfo->Fragments.size() == (size_t)ZSize)
+   {
+   }
 //   if ( ( ZSize == 1 ) && ( JPEGInfo->Fragments.size() > 1 ) )
 //   {
 //      // we have one frame split into several fragments
@@ -895,9 +915,9 @@ void PixelReadConvert::GrabInformationsFromHeader( File *header )
    if ( HasLUT )
    {
       // Just in case some access to a File element requires disk access.
-      LutRedDescriptor   = header->GetEntry( 0x0028, 0x1101 );
-      LutGreenDescriptor = header->GetEntry( 0x0028, 0x1102 );
-      LutBlueDescriptor  = header->GetEntry( 0x0028, 0x1103 );
+      LutRedDescriptor   = header->GetEntryValue( 0x0028, 0x1101 );
+      LutGreenDescriptor = header->GetEntryValue( 0x0028, 0x1102 );
+      LutBlueDescriptor  = header->GetEntryValue( 0x0028, 0x1103 );
    
       // Depending on the value of Document::MAX_SIZE_LOAD_ELEMENT_VALUE
       // [ refer to invocation of Document::SetMaxSizeLoadEntry() in