X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmJPEGFragmentsInfo.cxx;h=3102c4f3851427c07649f1f489066af312d94b0a;hb=35ee8ee8af32946514713d271177df8bb2298eb2;hp=f503f38839390a62bf631a5f407b40835e89c8af;hpb=70a3a0f95bf2240a6ef4b1d6523c0e6614437304;p=gdcm.git diff --git a/src/gdcmJPEGFragmentsInfo.cxx b/src/gdcmJPEGFragmentsInfo.cxx index f503f388..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: 2005/01/24 14:52:50 $ - Version: $Revision: 1.9 $ + 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,15 +17,19 @@ =========================================================================*/ #include "gdcmJPEGFragmentsInfo.h" +#include "gdcmDebug.h" + #include -namespace gdcm +namespace GDCM_NAME_SPACE { - +//------------------------------------------------------------------------- +// Constructor / Destructor JPEGFragmentsInfo::JPEGFragmentsInfo() - { - StateSuspension = 0; - } +{ + StateSuspension = 0; +} + /** * \brief Default destructor */ @@ -40,6 +44,61 @@ JPEGFragmentsInfo::~JPEGFragmentsInfo() 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. @@ -66,67 +125,5 @@ void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent ) 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; - } - -} - -void JPEGFragmentsInfo::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int numBytes, int length) -{ - // 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)->pimage = localRaw; - (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension); - // update pointer to image after some scanlines read: - localRaw = (*it)->pimage; - // Advance to next free location in Raw - // for next fragment decompression (if any) - - //localRaw += length * numBytes; - //std::cerr << "Used to increment by: " << length * numBytes << std::endl; - } -} - +//----------------------------------------------------------------------------- } // end namespace gdcm -