OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGeneralRasterInfo.h
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: MIT
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: David Burken
9 //
10 // Description:
11 //
12 // Contains class declaration for ossimGeneralRasterInfo
13 //*******************************************************************
14 // $Id: ossimGeneralRasterInfo.h 22197 2013-03-12 02:00:55Z dburken $
15 
16 #ifndef ossimGeneralRasterInfo_HEADER
17 #define ossimGeneralRasterInfo_HEADER 1
18 
19 #include <ossim/base/ossimObject.h>
20 #include <ossim/base/ossimCommon.h>
22 #include <ossim/base/ossimDrect.h>
25 #include <ossim/base/ossimIrect.h>
27 #include <vector>
28 
29 //---
30 // Forward class declarations.
31 //---
32 class ossimEnviHeader;
33 class ossimKeywordlist;
34 
40 {
41 public:
42 
44  {
47  ZEROES_TO_NULL_EDGES_ONLY
48  };
49 
50  enum
51  {
52  UNKNOWN = -1
53  };
54 
55  /* @brief default constructor */
57 
58  ossimGeneralRasterInfo(const std::vector<ossimFilename>& imageFileList,
59  ossimScalarType pixelType,
60  ossimInterleaveType il_type,
61  ossim_int32 numberOfBands,
62  ossim_int32 lines,
63  ossim_int32 samples,
64  ossim_int32 headerSize,
65  ossimFillMode nullsMode,
66  ossim_int32 pixelsToChop);
67 
68  ossimGeneralRasterInfo(const ossimKeywordlist& kwl, const char* prefix=0);
69 
70  /* @brief copy constructor */
72 
75 
76  virtual ~ossimGeneralRasterInfo ();
77 
81  const ossimIrect& imageRect() const;
82 
87  const ossimIrect& validImageRect() const;
88 
92  const ossimIrect& rawImageRect() const;
93 
98  const ossimIpt& subImageOffset() const;
99 
103  ossim_int32 headerSize() const;
104 
113  ossim_uint32 fillToNullsMode() const;
114 
118  void setFillToNullsMode(ossim_uint32 mode);
119 
124  inline ossim_int32 numberOfBands() const;
125 
130  inline ossim_int32 bytesPerPixel() const;
131 
138  ossim_int32 pixelsToChop() const;
139 
144  ossimInterleaveType interleaveType() const;
145 
149  inline ossim_int32 validLines() const;
150 
154  inline ossim_int32 rawLines() const;
155 
159  inline ossim_int32 bytesPerRawLine() const;
160 
164  inline ossim_int32 bytesPerValidLine() const;
165 
169  inline ossim_int32 validSamples() const;
170 
174  inline ossim_int32 rawSamples() const;
175 
179  inline std::streamoff offsetToFirstValidSample() const;
180 
181  const std::vector<ossimFilename>& getImageFileList() const;
182 
183  void setImageFileList(const std::vector<ossimFilename>& list);
184 
190  void setImageFile(const ossimFilename& file);
191 
192  void setHeaderSize(ossim_int32 headerSize);
193 
194  void setInterleaveType(ossimInterleaveType il_type);
195 
196  virtual std::ostream& print(std::ostream& out) const;
197 
198  void setImageRect(const ossimIrect& imageRect);
199 
200  void setValidImageRect(const ossimIrect &imageRect);
201 
202  void setRawImageRect(const ossimIrect &imageRect);
203 
204  void setSubImageOffset(const ossimIpt& d);
205 
206  ossimByteOrder getImageDataByteOrder() const;
207 
208  void setImageDataByteOrder(ossimByteOrder byteOrder);
213  virtual bool saveState(ossimKeywordlist& kwl,
214  const char* prefix=0) const;
215 
220  virtual bool loadState(const ossimKeywordlist& kwl,
221  const char* prefix=0);
222 
229  bool open( const ossimFilename& imageFile );
230 
232  inline const ossimImageMetaData& getImageMetaData() const;
233 
235  inline ossimImageMetaData& getImageMetaData();
236 
242  bool initializeFromEnviHdr( const ossimEnviHeader& enviHdr );
243 
244 private:
245 
251  bool initializeFromHdr( const ossimFilename& imageFile,
252  const ossimFilename& headerFile );
253 
259  bool initializeFromEnviHdr( const ossimFilename& headerFile );
260 
266  bool initializeFromXml( const ossimFilename& imageFile,
267  const ossimFilename& headerFile );
268 
281  ossim_int32 getBitsPerPixel( const ossimFilename& imageFile ) const;
282 
284  void clear();
285 
287  std::vector<ossimFilename> theImageFileList;
289 
294 
300 
305 
310 
315 
324 
329 
334 };
335 
336 
337 //---
338 // Inlines:
339 //
340 // These methods are used throughout raster read/write code; hence, inlines.
341 // Note that most of these are used in calculating std::streamoff which is
342 // a signed 64 bit integer on most machines; hence, the cast to an int from
343 // an unsigned int for convenience.
344 //---
346 {
347  return theMetaData;
348 }
349 
351 {
352  return theMetaData;
353 }
354 
356 {
357  return static_cast<ossim_int32>( theMetaData.getNumberOfBands() );
358 }
359 
361 {
362  return static_cast<ossim_int32>( theMetaData.getBytesPerPixel() );
363 }
364 
366 {
367  return static_cast<ossim_int32>(theValidImageRect.height());
368 }
369 
371 {
372  return static_cast<ossim_int32>(theRawImageRect.height());
373 }
374 
376 {
377  if (interleaveType() == OSSIM_BIP)
378  {
379  return rawSamples() * bytesPerPixel() * numberOfBands();
380  }
381  else
382  {
383  return rawSamples() * bytesPerPixel();
384  }
385 }
386 
388 {
389  if (interleaveType() == OSSIM_BIP)
390  {
391  return validSamples() * bytesPerPixel() * numberOfBands();
392  }
393  else
394  {
395  return validSamples() * bytesPerPixel();
396  }
397 }
398 
400 {
401  return static_cast<ossim_int32>(theValidImageRect.width());
402 }
403 
405 {
406  return static_cast<ossim_int32>(theRawImageRect.width());
407 }
408 
410 {
411  if (interleaveType() == OSSIM_BIP)
412  {
413  return headerSize() +
414  ( bytesPerRawLine() * validImageRect().ul().y ) +
416  }
417  else if (interleaveType() == OSSIM_BIL)
418  {
419  return headerSize() +
421  ( validImageRect().ul().x * bytesPerPixel() );
422  }
423  else // BSQ
424  {
425  return headerSize() +
426  ( bytesPerRawLine() * validImageRect().ul().y ) +
427  ( validImageRect().ul().x * bytesPerPixel() );
428  }
429 }
430 
431 #endif
ossim_int32 validSamples() const
Returns the number of samples within "theValidImageRect".
ossim_int32 bytesPerPixel() const
Bytes per pixel.
ossim_int32 theHeaderSize
Size of header in bytes.
ossimIrect theValidImageRect
The rectangle representing where the valid part of the image lies within "theRawImageRect".
#define OSSIMDLLEXPORT
ossim_int32 headerSize() const
Returns the size of header in bytes.
ossim_uint32 getBytesPerPixel() const
ossim_int32 thePixelsToChop
Amount of pixels to chop for each line edge.
const ossimIrect & validImageRect() const
Returns the rectangle of where the image is within the raster file.
Represents serializable keyword/value map.
ossimByteOrder theImageDataByteOrder
The byte order the image data is stored in.
ossimInterleaveType interleaveType() const
Enumerated in InterleaveTypeLUT.
std::streamoff offsetToFirstValidSample() const
Returns the offset in bytes to the first valid sample in the image.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimObject.cpp:95
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossim_uint32 height() const
Definition: ossimIrect.h:487
ossimImageMetaData theMetaData
std::vector< ossimFilename > theImageFileList
const ossimIpt & ul() const
Definition: ossimIrect.h:274
ossim_int32 bytesPerRawLine() const
Returns the number of bytes in a raw line.
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
ossim_int32 bytesPerValidLine() const
Returns the number of bytes in a valid line.
ossim_int32 validLines() const
Returns the number of lines within "theValidImageRect".
ossim_uint32 getNumberOfBands() const
virtual std::ostream & print(std::ostream &out) const
Generic print method.
ossimInterleaveType theInterleaveType
unsigned int ossim_uint32
ossim_int32 rawLines() const
Returns the number of lines within "theRawImageRect".
ossimFillMode theSetNullsMode
Mode of how to handle pixels on import.
ossim_int32 rawSamples() const
Returns the number of samples within "theRawImageRect".
ossimByteOrder
ossimInterleaveType
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimScalarType
OSSIM_DLL ossim_uint32 getBitsPerPixel(ossimScalarType scalarType)
Get bits per pixel for a given scalar type.
ossimIrect theImageRect
The valid image rectangle normalized to be zero based.
ossimIpt theSubImageOffset
The offset from the full-image origin to this image&#39;s origin.
ossim_int32 y
Definition: ossimIpt.h:142
ossimIrect theRawImageRect
The zero based rectangle of the entire image not including any header.
ossimReferenced & operator=(const ossimReferenced &)
Class for reading and writing an ENVI (The Environment for Visualizing Images) header file...
const ossimImageMetaData & getImageMetaData() const
ossim_int32 x
Definition: ossimIpt.h:141
ossim_int32 numberOfBands() const
Number of bands.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32