X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmJPEGFragmentsInfo.cxx;h=ddfaaabd5d55cfed55a3f36191e5f04be58ee2a8;hb=0ad9dae4659b21bfd5c834c1af724eab4dcdf4f6;hp=88725b92aa4553fdafc1272bca55ef38ce1ec885;hpb=e8caac199c2683cb0f118c42c61dc6aec85b1eec;p=gdcm.git diff --git a/src/gdcmJPEGFragmentsInfo.cxx b/src/gdcmJPEGFragmentsInfo.cxx index 88725b92..ddfaaabd 100644 --- a/src/gdcmJPEGFragmentsInfo.cxx +++ b/src/gdcmJPEGFragmentsInfo.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $ Language: C++ - Date: $Date: 2005/01/16 04:50:42 $ - Version: $Revision: 1.5 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -17,6 +17,7 @@ =========================================================================*/ #include "gdcmJPEGFragmentsInfo.h" +#include namespace gdcm { @@ -37,14 +38,15 @@ JPEGFragmentsInfo::~JPEGFragmentsInfo() /** * \brief Print self. - * @param indent Indentation string to be prepended during printing. * @param os Stream to print to. + * @param indent Indentation string to be prepended during printing. */ -void JPEGFragmentsInfo::Print( std::ostream &os, std::string const & indent ) +void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent ) { + os << std::endl; os << indent << "----------------- JPEG fragments --------------------------------" - << std::endl; + << std::endl << std::endl; os << indent << "Total number of fragments : " << Fragments.size() << std::endl; @@ -56,9 +58,48 @@ void JPEGFragmentsInfo::Print( std::ostream &os, std::string const & indent ) os << indent << " fragment number :" << fragmentNumber++; (*it)->Print( os, indent + " "); - os << std::endl; } + os << std::endl; } +/** + * \brief Calculate sum of all fragments length and return total + * @return Total size of JPEG fragments length + */ +size_t JPEGFragmentsInfo::GetFragmentsLength() +{ + // Loop on the fragment[s] to get total length + size_t totalLength = 0; + JPEGFragmentsList::const_iterator it; + for( it = Fragments.begin(); + it != Fragments.end(); + ++it ) + { + totalLength += (*it)->Length; + } + return totalLength; +} + +/** + * \brief Read the all the JPEG Fragment into the input buffer + */ +void JPEGFragmentsInfo::ReadAllFragments(std::ifstream *fp, JOCTET *buffer ) +{ + JOCTET *p = buffer; + + // Loop on the fragment[s] + JPEGFragmentsList::const_iterator it; + for( it = Fragments.begin(); + it != Fragments.end(); + ++it ) + { + fp->seekg( (*it)->Offset, std::ios::beg); + size_t len = (*it)->Length; + fp->read((char *)p,len); + p += len; + } + +} } // end namespace gdcm +