OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimRpfCompressionSection.cpp
Go to the documentation of this file.
7 #include <cstring> // for memset
8 #include <iterator>
9 
12 {
13  unsigned long size = (data.theNumberOfValuesPerLookup*data.theNumberOfLookupValues*
15 
16  out << "theTableId: " << data.theTableId
17  << "\ntheNumberOfLookupValues: " << data.theNumberOfLookupValues
18  << "\ntheCompressionLookupValueBitLength: " << data.theCompressionLookupValueBitLength
19  << "\ntheNumberOfValuesPerLookup: " << data.theNumberOfValuesPerLookup
20  << "\nData Size in bytes: "
21  << size;
22 
23  return out;
24 }
25 
26 
28  :theTableId(0),
29  theNumberOfLookupValues(0),
30  theCompressionLookupValueBitLength(0),
31  theNumberOfValuesPerLookup(0),
32  theData(NULL)
33 {
34 }
35 
38  :theNumberOfLookupValues(0),
39  theCompressionLookupValueBitLength(0),
40  theNumberOfValuesPerLookup(0),
41  theData(NULL)
42 {
43  *this = rhs;
44 }
45 
48 {
49  if(this != &rhs)
50  {
51  if(theData)
52  {
53  delete [] theData;
54  theData = 0;
55  }
56 
57  if(rhs.theData)
58  {
59  theTableId = rhs.theTableId;
63 
64  unsigned long size = (theNumberOfValuesPerLookup*
67  if(size > 0)
68  {
69  theData = new unsigned char[size];
70  memcpy(theData, rhs.theData, size);
71  }
72  }
73  else
74  {
75  theTableId = 0;
79  }
80  }
81 
82  return *this;
83 }
84 
86 {
87  if(theData)
88  {
89  delete [] theData;
90  theData = 0;
91  }
92 }
93 
94 
96  std::ostream& out, const ossimRpfCompressionSection& data)
97 {
98  data.print(out);
99  return out;
100 }
101 
103  :theSubheader(NULL)
104 {
106 }
107 
109 {
110  if(theSubheader)
111  {
112  delete theSubheader;
113  theSubheader = NULL;
114  }
115 }
116 
119 {
121 
122  if(in&&theSubheader)
123  {
124  result = theSubheader->parseStream(in, byteOrder);
125 
126  if(result == ossimErrorCodes::OSSIM_OK)
127  {
128  ossimEndian anEndian;
130 
131  in.read((char*)&theCompressionLookupOffsetTableOffset, 4);
133 
134  if(byteOrder != anEndian.getSystemEndianType())
135  {
138  }
139 
141  {
142  // clear the table
143  theTable.clear();
144 
145  // resize it
147 
148  // now populate it
149  for(long index = 0;
151  ++index)
152  {
153  record.parseStream(in, byteOrder);
154  unsigned long rememberLocation = in.tellg();
155  in.seekg(record.getCompressionLookupTableOffset()+
156  theSubheader->getEndOffset(), std::ios_base::beg);
157 
158  theTable[index].theTableId = record.getCompressionLookupTableId();
159  theTable[index].theNumberOfLookupValues = record.getNumberOfCompressionLookupRecords();
160  theTable[index].theCompressionLookupValueBitLength = record.getCompressionLookupValueBitLength();
161  theTable[index].theNumberOfValuesPerLookup = record.getNumberOfValuesPerCompressionLookupRecord();
162 
163  // store the information about this compress/decompress algorithm
164  // I am not sure but I will assume that the bit length can be
165  // arbitrary. In other words if someone says that the bit length of
166  // the lookup value is 12 this should be handled ok.
167  //
168  unsigned long size = (theTable[index].theNumberOfValuesPerLookup*
169  theTable[index].theNumberOfLookupValues*
170  theTable[index].theCompressionLookupValueBitLength)/8;
171 
172  theTable[index].theData = new unsigned char[size];
173 
174  in.read( (char*)theTable[index].theData, size);
175 
176  in.seekg(rememberLocation, std::ios_base::beg);
177  }
178  }
179  }
180  }
181  else
182  {
184  }
185 
186  return result;
187 }
188 
190 {
191  if(theSubheader)
192  {
193  out << *theSubheader << "\n";
194  copy(theTable.begin(),
195  theTable.end(),
196  std::ostream_iterator<ossimRpfCompressionOffsetTableData>(out, "\n"));
197  }
198 }
199 
ossim_int32 ossimErrorCode
static const ossimErrorCode OSSIM_OK
ossimRpfCompressionSectionSubheader * theSubheader
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
static const ossimErrorCode OSSIM_ERROR
std::vector< ossimRpfCompressionOffsetTableData > theTable
ossimErrorCode parseStream(ossim::istream &in, ossimByteOrder byteOrder)
ossimErrorCode parseStream(ossim::istream &in, ossimByteOrder byteOrder)
yy_size_t size
void print(std::ostream &out) const
ossimErrorCode parseStream(ossim::istream &in, ossimByteOrder byteOrder)
ossimByteOrder
ossimByteOrder getSystemEndianType() const
Definition: ossimEndian.h:78
std::ostream & operator<<(std::ostream &out, const ossimRpfCompressionOffsetTableData &data)
const ossimRpfCompressionOffsetTableData & operator=(const ossimRpfCompressionOffsetTableData &rhs)
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossim_uint16 theCompressionLookupTableOffsetRecordLength
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23