]> Creatis software - gdcm.git/blobdiff - src/gdcmJPEGFragmentsInfo.cxx
ENH: Huge commit to remove the previous implementation for jpeg/fragments/multiframes...
[gdcm.git] / src / gdcmJPEGFragmentsInfo.cxx
index ddfaaabd5d55cfed55a3f36191e5f04be58ee2a8..489ab2fe1a82c33f81c301089ced9d73dc45a800 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/23 10:12:34 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/01/31 03:22:25 $
+  Version:   $Revision: 1.14 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 =========================================================================*/
 
 #include "gdcmJPEGFragmentsInfo.h"
+#include "gdcmDebug.h"
+
 #include <fstream>
 
 namespace gdcm 
 {
 
+JPEGFragmentsInfo::JPEGFragmentsInfo()
+{
+   StateSuspension = 0;
+}
+
 /**
  * \brief Default destructor
  */
@@ -75,7 +82,7 @@ size_t JPEGFragmentsInfo::GetFragmentsLength()
         it != Fragments.end();
         ++it )
    {
-      totalLength += (*it)->Length;
+      totalLength += (*it)->GetLength();
    }
    return totalLength;
 }
@@ -93,13 +100,65 @@ void JPEGFragmentsInfo::ReadAllFragments(std::ifstream *fp, JOCTET *buffer )
         it != Fragments.end();
         ++it )
    {
-      fp->seekg( (*it)->Offset, std::ios::beg);
-      size_t len = (*it)->Length;
+      fp->seekg( (*it)->GetOffset(), std::ios::beg);
+      size_t len = (*it)->GetLength();
       fp->read((char *)p,len);
       p += len;
    }
 
 }
 
+// to avoid warnings
+void JPEGFragmentsInfo::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int , int )
+{
+   // Pointer to the Raw image
+   uint8_t *localRaw = buffer;
+
+  // Loop on the fragment[s]
+   JPEGFragmentsList::const_iterator it;
+   for( it  = Fragments.begin();
+        it != Fragments.end();
+        ++it )
+   {
+     //(*it)->pimage = localRaw;
+     (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension);
+     // update pointer to image after some scanlines read:
+     localRaw = (*it)->GetImage();
+      // Advance to next free location in Raw 
+      // for next fragment decompression (if any)
+
+      //localRaw += length * numBytes;
+     //std::cerr << "Used to increment by: " << length * numBytes << std::endl;
+   }
+}
+
+void JPEGFragmentsInfo::AddFragment(JPEGFragment *fragment)
+{
+   Fragments.push_back(fragment);
+}
+
+JPEGFragment *JPEGFragmentsInfo::GetFirstFragment()
+{
+   ItFragments = Fragments.begin();
+   if (ItFragments != Fragments.end())
+      return  *ItFragments;
+   return NULL;
+}
+
+JPEGFragment *JPEGFragmentsInfo::GetNextFragment()
+{
+   gdcmAssertMacro (ItFragments != Fragments.end());
+
+   ++ItFragments;
+   if (ItFragments != Fragments.end())
+      return  *ItFragments;
+   return NULL;
+}
+
+unsigned int JPEGFragmentsInfo::GetFragmentCount()
+{
+   return Fragments.size();
+}
+
 } // end namespace gdcm