00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "gdcmJPEGFragmentsInfo.h"
00020 #include "gdcmDebug.h"
00021
00022 #include <fstream>
00023
00024 namespace gdcm
00025 {
00026
00027
00028 JPEGFragmentsInfo::JPEGFragmentsInfo()
00029 {
00030 StateSuspension = 0;
00031 }
00032
00036 JPEGFragmentsInfo::~JPEGFragmentsInfo()
00037 {
00038 for(JPEGFragmentsList::iterator it = Fragments.begin();
00039 it != Fragments.end();
00040 ++it )
00041 {
00042 delete *it;
00043 }
00044 Fragments.clear();
00045 }
00046
00047
00048
00049 void JPEGFragmentsInfo::DecompressFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int , int )
00050 {
00051
00052 uint8_t *localRaw = buffer;
00053
00054
00055 JPEGFragmentsList::const_iterator it;
00056 for( it = Fragments.begin();
00057 it != Fragments.end();
00058 ++it )
00059 {
00060 (*it)->DecompressJPEGFramesFromFile(fp, localRaw, nBits, StateSuspension);
00061
00062 localRaw = (*it)->GetImage();
00063 }
00064 }
00065
00066 void JPEGFragmentsInfo::AddFragment(JPEGFragment *fragment)
00067 {
00068 Fragments.push_back(fragment);
00069 }
00070
00071 JPEGFragment *JPEGFragmentsInfo::GetFirstFragment()
00072 {
00073 ItFragments = Fragments.begin();
00074 if (ItFragments != Fragments.end())
00075 return *ItFragments;
00076 return NULL;
00077 }
00078
00079 JPEGFragment *JPEGFragmentsInfo::GetNextFragment()
00080 {
00081 gdcmAssertMacro (ItFragments != Fragments.end());
00082
00083 ++ItFragments;
00084 if (ItFragments != Fragments.end())
00085 return *ItFragments;
00086 return NULL;
00087 }
00088
00089 unsigned int JPEGFragmentsInfo::GetFragmentCount()
00090 {
00091 return Fragments.size();
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00107 void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent )
00108 {
00109 os << std::endl;
00110 os << indent
00111 << "----------------- JPEG fragments --------------------------------"
00112 << std::endl << std::endl;
00113 os << indent
00114 << "Total number of fragments : " << Fragments.size()
00115 << std::endl;
00116 int fragmentNumber = 0;
00117 for(JPEGFragmentsList::iterator it = Fragments.begin();
00118 it != Fragments.end();
00119 ++it)
00120 {
00121 os << indent
00122 << " fragment number :" << fragmentNumber++;
00123 (*it)->Print( os, indent + " ");
00124 }
00125 os << std::endl;
00126 }
00127
00128
00129 }