1 /*=========================================================================
4 Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $
6 Date: $Date: 2005/01/24 14:52:50 $
7 Version: $Revision: 1.9 $
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"
25 JPEGFragmentsInfo::JPEGFragmentsInfo()
30 * \brief Default destructor
32 JPEGFragmentsInfo::~JPEGFragmentsInfo()
34 for(JPEGFragmentsList::iterator it = Fragments.begin();
35 it != Fragments.end();
45 * @param os Stream to print to.
46 * @param indent Indentation string to be prepended during printing.
48 void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent )
52 << "----------------- JPEG fragments --------------------------------"
53 << std::endl << std::endl;
55 << "Total number of fragments : " << Fragments.size()
57 int fragmentNumber = 0;
58 for(JPEGFragmentsList::iterator it = Fragments.begin();
59 it != Fragments.end();
63 << " fragment number :" << fragmentNumber++;
64 (*it)->Print( os, indent + " ");
70 * \brief Calculate sum of all fragments length and return total
71 * @return Total size of JPEG fragments length
73 size_t JPEGFragmentsInfo::GetFragmentsLength()
75 // Loop on the fragment[s] to get total length
76 size_t totalLength = 0;
77 JPEGFragmentsList::const_iterator it;
78 for( it = Fragments.begin();
79 it != Fragments.end();
82 totalLength += (*it)->Length;
88 * \brief Read the all the JPEG Fragment into the input buffer
90 void JPEGFragmentsInfo::ReadAllFragments(std::ifstream *fp, JOCTET *buffer )
94 // Loop on the fragment[s]
95 JPEGFragmentsList::const_iterator it;
96 for( it = Fragments.begin();
97 it != Fragments.end();
100 fp->seekg( (*it)->Offset, std::ios::beg);
101 size_t len = (*it)->Length;
102 fp->read((char *)p,len);
108 void JPEGFragmentsInfo::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int numBytes, int length)
110 // Pointer to the Raw image
111 uint8_t *localRaw = buffer;
113 // Loop on the fragment[s]
114 JPEGFragmentsList::const_iterator it;
115 for( it = Fragments.begin();
116 it != Fragments.end();
119 //(*it)->pimage = localRaw;
120 (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension);
121 // update pointer to image after some scanlines read:
122 localRaw = (*it)->pimage;
123 // Advance to next free location in Raw
124 // for next fragment decompression (if any)
126 //localRaw += length * numBytes;
127 //std::cerr << "Used to increment by: " << length * numBytes << std::endl;
131 } // end namespace gdcm