1 /*=========================================================================
4 Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $
6 Date: $Date: 2005/01/23 10:12:34 $
7 Version: $Revision: 1.8 $
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"
26 * \brief Default destructor
28 JPEGFragmentsInfo::~JPEGFragmentsInfo()
30 for(JPEGFragmentsList::iterator it = Fragments.begin();
31 it != Fragments.end();
41 * @param os Stream to print to.
42 * @param indent Indentation string to be prepended during printing.
44 void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent )
48 << "----------------- JPEG fragments --------------------------------"
49 << std::endl << std::endl;
51 << "Total number of fragments : " << Fragments.size()
53 int fragmentNumber = 0;
54 for(JPEGFragmentsList::iterator it = Fragments.begin();
55 it != Fragments.end();
59 << " fragment number :" << fragmentNumber++;
60 (*it)->Print( os, indent + " ");
66 * \brief Calculate sum of all fragments length and return total
67 * @return Total size of JPEG fragments length
69 size_t JPEGFragmentsInfo::GetFragmentsLength()
71 // Loop on the fragment[s] to get total length
72 size_t totalLength = 0;
73 JPEGFragmentsList::const_iterator it;
74 for( it = Fragments.begin();
75 it != Fragments.end();
78 totalLength += (*it)->Length;
84 * \brief Read the all the JPEG Fragment into the input buffer
86 void JPEGFragmentsInfo::ReadAllFragments(std::ifstream *fp, JOCTET *buffer )
90 // Loop on the fragment[s]
91 JPEGFragmentsList::const_iterator it;
92 for( it = Fragments.begin();
93 it != Fragments.end();
96 fp->seekg( (*it)->Offset, std::ios::beg);
97 size_t len = (*it)->Length;
98 fp->read((char *)p,len);
104 } // end namespace gdcm