]> Creatis software - gdcm.git/blobdiff - src/gdcmJPEGFragment.cxx
* Remove friend classes between DocEntry and File
[gdcm.git] / src / gdcmJPEGFragment.cxx
index 188f82266e7f7b2187468947d888e65a690aa5c5..8ba7dad4f67b3fc90ae86cb7697e160a8da6a66b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJPEGFragment.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/17 03:05:55 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/01/26 11:42:02 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,16 +23,21 @@ 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 (std::ifstream *fp, void *image_buffer);
+//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, 
                                 void *image_buffer,
                                 size_t *howManyRead, size_t *howManyWritten);
 //
 // For JPEG 12 Bits, body in file gdcmJpeg12.cxx
-bool gdcm_read_JPEG_file12 (std::ifstream *fp, void *image_buffer);
+//bool gdcm_read_JPEG_file12 (JPEGFragment *frag, std::ifstream *fp, void *image_buffer);
 bool gdcm_read_JPEG_memory12   (const JOCTET *buffer, const size_t buflen, 
                                 void *image_buffer,
                                 size_t *howManyRead, size_t *howManyWritten);
@@ -40,7 +45,7 @@ bool gdcm_read_JPEG_memory12   (const JOCTET *buffer, const size_t buflen,
 // For JPEG 16 Bits, body in file gdcmJpeg16.cxx
 // Beware this is misleading there is no 16bits DCT algorithm, only
 // jpeg lossless compression exist in 16bits.
-bool gdcm_read_JPEG_file16 (std::ifstream *fp, void *image_buffer);
+//bool gdcm_read_JPEG_file16 (JPEGFragment *frag, std::ifstream *fp, void *image_buffer);
 bool gdcm_read_JPEG_memory16   (const JOCTET *buffer, const size_t buflen, 
                                 void* image_buffer,
                                 size_t *howManyRead, size_t *howManyWritten);
@@ -52,6 +57,11 @@ JPEGFragment::JPEGFragment()
 {
    Offset = 0;
    Length = 0;
+
+//   StateSuspension = 0;
+//   void *SampBuffer;
+   pImage = 0;
+
 }
 
 /**
@@ -69,10 +79,14 @@ void JPEGFragment::Print( std::ostream &os, std::string indent )
 
 /**
  * \brief Decompress 8bits JPEG Fragment
+ * @param fp ifstream to write to
  * @param buffer     output (data decompress)
  * @param nBits      8/12 or 16 bits jpeg
+ * @param statesuspension state suspension
  */
-void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits)
+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);
@@ -80,7 +94,7 @@ void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buff
    if ( nBits == 8 )
    {
       // JPEG Lossy : call to IJG 6b
-      if ( ! gdcm_read_JPEG_file8( fp, buffer) )
+      if ( ! this->gdcm_read_JPEG_file8( fp, buffer, statesuspension) )
       {
          //return false;
       }
@@ -88,7 +102,7 @@ void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buff
    else if ( nBits <= 12 )
    {
       // Reading Fragment pixels
-      if ( ! gdcm_read_JPEG_file12 ( fp, buffer) )
+      if ( ! this->gdcm_read_JPEG_file12 ( fp, buffer, statesuspension) )
       {
          //return false;
       }
@@ -96,7 +110,7 @@ void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buff
    else if ( nBits <= 16 )
    {
       // Reading Fragment pixels
-      if ( ! gdcm_read_JPEG_file16 ( fp, buffer) )
+      if ( ! this->gdcm_read_JPEG_file16 ( fp, buffer, statesuspension) )
       {
          //return false;
       }
@@ -104,6 +118,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;
@@ -111,7 +128,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;
@@ -149,6 +167,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;
@@ -157,7 +178,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 )
    {
@@ -196,6 +219,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;