]> Creatis software - gdcm.git/blob - src/gdcmJPEGFragmentsInfo.cxx
STYLE: remove GetNextttttt + minor Doc
[gdcm.git] / src / gdcmJPEGFragmentsInfo.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/31 04:15:33 $
7   Version:   $Revision: 1.16 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmJPEGFragmentsInfo.h"
20 #include "gdcmDebug.h"
21
22 #include <fstream>
23
24 namespace gdcm 
25 {
26
27 JPEGFragmentsInfo::JPEGFragmentsInfo()
28 {
29    StateSuspension = 0;
30 }
31
32 /**
33  * \brief Default destructor
34  */
35 JPEGFragmentsInfo::~JPEGFragmentsInfo()
36 {
37    for(JPEGFragmentsList::iterator it  = Fragments.begin();
38                                    it != Fragments.end();
39                                  ++it )
40    {
41       delete *it;
42    }
43    Fragments.clear();
44 }
45
46 /**
47  * \brief        Print self.
48  * @param os     Stream to print to.
49  * @param indent Indentation string to be prepended during printing.
50  */
51 void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent )
52 {
53    os << std::endl;
54    os << indent
55       << "----------------- JPEG fragments --------------------------------"
56       << std::endl << std::endl;
57    os << indent
58       << "Total number of fragments : " << Fragments.size()
59       << std::endl;
60    int fragmentNumber = 0;
61    for(JPEGFragmentsList::iterator it  = Fragments.begin();
62                                    it != Fragments.end();
63                                  ++it)
64    {
65       os << indent
66          << "   fragment number :" << fragmentNumber++;
67       (*it)->Print( os, indent + "   ");
68    }
69    os << std::endl;
70 }
71
72 void JPEGFragmentsInfo::DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int , int )
73 {
74    // Pointer to the Raw image
75    uint8_t *localRaw = buffer;
76
77   // Loop on the fragment[s]
78    JPEGFragmentsList::const_iterator it;
79    for( it  = Fragments.begin();
80         it != Fragments.end();
81         ++it )
82    {
83      (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension);
84      // update pointer to image after some scanlines read:
85      localRaw = (*it)->GetImage();
86    }
87 }
88
89 void JPEGFragmentsInfo::AddFragment(JPEGFragment *fragment)
90 {
91    Fragments.push_back(fragment);
92 }
93
94 JPEGFragment *JPEGFragmentsInfo::GetFirstFragment()
95 {
96    ItFragments = Fragments.begin();
97    if (ItFragments != Fragments.end())
98       return  *ItFragments;
99    return NULL;
100 }
101
102 JPEGFragment *JPEGFragmentsInfo::GetNextFragment()
103 {
104    gdcmAssertMacro (ItFragments != Fragments.end());
105
106    ++ItFragments;
107    if (ItFragments != Fragments.end())
108       return  *ItFragments;
109    return NULL;
110 }
111
112 unsigned int JPEGFragmentsInfo::GetFragmentCount()
113 {
114    return Fragments.size();
115 }
116
117 } // end namespace gdcm
118