1 /*=========================================================================
4 Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $
6 Date: $Date: 2005/01/17 03:05:55 $
7 Version: $Revision: 1.7 $
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 indent Indentation string to be prepended during printing.
42 * @param os Stream to print to.
44 void JPEGFragmentsInfo::Print( std::ostream &os, std::string const & indent )
47 << "----------------- JPEG fragments --------------------------------"
50 << "Total number of fragments : " << Fragments.size()
52 int fragmentNumber = 0;
53 for(JPEGFragmentsList::iterator it = Fragments.begin();
54 it != Fragments.end();
58 << " fragment number :" << fragmentNumber++;
59 (*it)->Print( os, indent + " ");
65 * \brief Calculate sum of all fragments lenght and return total
66 * @return Total size of JPEG fragments length
68 size_t JPEGFragmentsInfo::GetFragmentsLength()
70 // Loop on the fragment[s] to get total length
71 size_t totalLength = 0;
72 JPEGFragmentsList::const_iterator it;
73 for( it = Fragments.begin();
74 it != Fragments.end();
77 totalLength += (*it)->Length;
83 * \brief Read the all the JPEG Fragment into the input buffer
85 void JPEGFragmentsInfo::ReadAllFragments(std::ifstream *fp, JOCTET *buffer )
89 // Loop on the fragment[s]
90 JPEGFragmentsList::const_iterator it;
91 for( it = Fragments.begin();
92 it != Fragments.end();
95 fp->seekg( (*it)->Offset, std::ios::beg);
96 size_t len = (*it)->Length;
97 fp->read((char *)p,len);
103 } // end namespace gdcm