1 /*=========================================================================
4 Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $
6 Date: $Date: 2005/02/01 10:29:55 $
7 Version: $Revision: 1.18 $
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"
26 //-------------------------------------------------------------------------
27 // Constructor / Destructor
28 JPEGFragmentsInfo::JPEGFragmentsInfo()
34 * \brief Default destructor
36 JPEGFragmentsInfo::~JPEGFragmentsInfo()
38 for(JPEGFragmentsList::iterator it = Fragments.begin();
39 it != Fragments.end();
47 //-----------------------------------------------------------------------------
49 void JPEGFragmentsInfo::DecompressFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int , int )
51 // Pointer to the Raw image
52 uint8_t *localRaw = buffer;
54 // Loop on the fragment[s]
55 JPEGFragmentsList::const_iterator it;
56 for( it = Fragments.begin();
57 it != Fragments.end();
60 (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension);
61 // update pointer to image after some scanlines read:
62 localRaw = (*it)->GetImage();
66 void JPEGFragmentsInfo::AddFragment(JPEGFragment *fragment)
68 Fragments.push_back(fragment);
71 JPEGFragment *JPEGFragmentsInfo::GetFirstFragment()
73 ItFragments = Fragments.begin();
74 if (ItFragments != Fragments.end())
79 JPEGFragment *JPEGFragmentsInfo::GetNextFragment()
81 gdcmAssertMacro (ItFragments != Fragments.end());
84 if (ItFragments != Fragments.end())
89 unsigned int JPEGFragmentsInfo::GetFragmentCount()
91 return Fragments.size();
94 //-----------------------------------------------------------------------------
97 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
104 * @param os Stream to print to.
105 * @param indent Indentation string to be prepended during printing.
107 void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent )
111 << "----------------- JPEG fragments --------------------------------"
112 << std::endl << std::endl;
114 << "Total number of fragments : " << Fragments.size()
116 int fragmentNumber = 0;
117 for(JPEGFragmentsList::iterator it = Fragments.begin();
118 it != Fragments.end();
122 << " fragment number :" << fragmentNumber++;
123 (*it)->Print( os, indent + " ");
128 //-----------------------------------------------------------------------------
129 } // end namespace gdcm