X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmJPEGFragmentsInfo.cxx;h=3102c4f3851427c07649f1f489066af312d94b0a;hb=b06cbd9177331d793223eac6bf8b2bccf874e7e3;hp=41f802d39dd9e34eb1a55605f81a1ab5e5e567fe;hpb=1d69b92978803204089d270599133917d944c651;p=gdcm.git diff --git a/src/gdcmJPEGFragmentsInfo.cxx b/src/gdcmJPEGFragmentsInfo.cxx index 41f802d3..3102c4f3 100644 --- a/src/gdcmJPEGFragmentsInfo.cxx +++ b/src/gdcmJPEGFragmentsInfo.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $ Language: C++ - Date: $Date: 2004/10/12 04:35:46 $ - Version: $Revision: 1.2 $ + Date: $Date: 2007/05/23 14:18:10 $ + Version: $Revision: 1.21 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -17,18 +17,113 @@ =========================================================================*/ #include "gdcmJPEGFragmentsInfo.h" +#include "gdcmDebug.h" -namespace gdcm +#include + +namespace GDCM_NAME_SPACE +{ +//------------------------------------------------------------------------- +// Constructor / Destructor +JPEGFragmentsInfo::JPEGFragmentsInfo() { + StateSuspension = 0; +} +/** + * \brief Default destructor + */ JPEGFragmentsInfo::~JPEGFragmentsInfo() { for(JPEGFragmentsList::iterator it = Fragments.begin(); it != Fragments.end(); ++it ) { - delete (*it); + delete *it; } Fragments.clear(); } + +//----------------------------------------------------------------------------- +// Public +void JPEGFragmentsInfo::DecompressFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int , int ) +{ + // Pointer to the Raw image + uint8_t *localRaw = buffer; + + // Loop on the fragment[s] + JPEGFragmentsList::const_iterator it; + for( it = Fragments.begin(); + it != Fragments.end(); + ++it ) + { + (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension); + // update pointer to image after some scanlines read: + localRaw = (*it)->GetImage(); + } +} + +void JPEGFragmentsInfo::AddFragment(JPEGFragment *fragment) +{ + Fragments.push_back(fragment); +} + +JPEGFragment *JPEGFragmentsInfo::GetFirstFragment() +{ + ItFragments = Fragments.begin(); + if (ItFragments != Fragments.end()) + return *ItFragments; + return NULL; +} + +JPEGFragment *JPEGFragmentsInfo::GetNextFragment() +{ + gdcmAssertMacro (ItFragments != Fragments.end()); + + ++ItFragments; + if (ItFragments != Fragments.end()) + return *ItFragments; + return NULL; +} + +unsigned int JPEGFragmentsInfo::GetFragmentCount() +{ + return Fragments.size(); +} + +//----------------------------------------------------------------------------- +// Protected + +//----------------------------------------------------------------------------- +// Private + +//----------------------------------------------------------------------------- +// Print +/** + * \brief Print self. + * @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 ) +{ + os << std::endl; + os << indent + << "----------------- JPEG fragments --------------------------------" + << std::endl << std::endl; + os << indent + << "Total number of fragments : " << Fragments.size() + << std::endl; + int fragmentNumber = 0; + for(JPEGFragmentsList::iterator it = Fragments.begin(); + it != Fragments.end(); + ++it) + { + os << indent + << " fragment number :" << fragmentNumber++; + (*it)->Print( os, indent + " "); + } + os << std::endl; +} + +//----------------------------------------------------------------------------- } // end namespace gdcm