1 /*=========================================================================
4 Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $
6 Date: $Date: 2005/01/31 05:24:21 $
7 Version: $Revision: 1.17 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmJPEGFragmentsInfo.h"
20 #include "gdcmDebug.h"
27 JPEGFragmentsInfo::JPEGFragmentsInfo()
33 * \brief Default destructor
35 JPEGFragmentsInfo::~JPEGFragmentsInfo()
37 for(JPEGFragmentsList::iterator it = Fragments.begin();
38 it != Fragments.end();
48 * @param os Stream to print to.
49 * @param indent Indentation string to be prepended during printing.
51 void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent )
55 << "----------------- JPEG fragments --------------------------------"
56 << std::endl << std::endl;
58 << "Total number of fragments : " << Fragments.size()
60 int fragmentNumber = 0;
61 for(JPEGFragmentsList::iterator it = Fragments.begin();
62 it != Fragments.end();
66 << " fragment number :" << fragmentNumber++;
67 (*it)->Print( os, indent + " ");
72 void JPEGFragmentsInfo::DecompressFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int , int )
74 // Pointer to the Raw image
75 uint8_t *localRaw = buffer;
77 // Loop on the fragment[s]
78 JPEGFragmentsList::const_iterator it;
79 for( it = Fragments.begin();
80 it != Fragments.end();
83 (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension);
84 // update pointer to image after some scanlines read:
85 localRaw = (*it)->GetImage();
89 void JPEGFragmentsInfo::AddFragment(JPEGFragment *fragment)
91 Fragments.push_back(fragment);
94 JPEGFragment *JPEGFragmentsInfo::GetFirstFragment()
96 ItFragments = Fragments.begin();
97 if (ItFragments != Fragments.end())
102 JPEGFragment *JPEGFragmentsInfo::GetNextFragment()
104 gdcmAssertMacro (ItFragments != Fragments.end());
107 if (ItFragments != Fragments.end())
112 unsigned int JPEGFragmentsInfo::GetFragmentCount()
114 return Fragments.size();
117 } // end namespace gdcm