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