OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimPngReader.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description: OSSIM Portable Network Graphics (PNG) reader (tile source).
10 //
11 //----------------------------------------------------------------------------
12 // $Id: ossimPngReader.h 23355 2015-06-01 23:55:15Z dburken $
13 #ifndef ossimPngReader_HEADER
14 #define ossimPngReader_HEADER 1
15 
19 #include <ossim/base/ossimIosFwd.h>
20 #include <png.h>
21 #include <memory>
22 #include <vector>
23 
24 class ossimImageData;
25 
27 {
28 public:
29 
31  {
37  };
38 
41 
43  virtual ~ossimPngReader();
44 
46  virtual ossimString getShortName() const;
47 
49  virtual ossimString getLongName() const;
50 
52  virtual ossimString getClassName() const;
53 
60  ossim_uint32 resLevel=0);
73  virtual bool getTile(ossimImageData* result, ossim_uint32 resLevel=0);
74 
79  virtual ossim_uint32 getNumberOfInputBands() const;
80 
86  virtual ossim_uint32 getNumberOfOutputBands()const;
87 
92  virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level = 0) const;
93 
98  virtual ossim_uint32 getNumberOfSamples(ossim_uint32 reduced_res_level = 0) const;
99 
104  virtual ossimIrect getImageRectangle(ossim_uint32 reduced_res_level = 0) const;
105 
110  virtual bool saveState(ossimKeywordlist& kwl,
111  const char* prefix=0)const;
112 
117  virtual bool loadState(const ossimKeywordlist& kwl,
118  const char* prefix=0);
119 
129  virtual void setProperty(ossimRefPtr<ossimProperty> property);
130 
135  virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name) const;
136 
141  virtual void getPropertyNames(std::vector<ossimString>& propertyNames) const;
142 
146  virtual ossimScalarType getOutputScalarType() const;
147 
151  virtual ossim_uint32 getTileWidth() const;
152 
156  virtual ossim_uint32 getTileHeight() const;
157 
164  virtual ossim_uint32 getImageTileWidth() const;
165 
172  virtual ossim_uint32 getImageTileHeight() const;
173 
174  bool isOpen()const;
175 
176  virtual double getMaxPixelValue(ossim_uint32 band = 0)const;
177 
188  virtual bool open( std::shared_ptr<ossim::istream>& str,
189  const std::string& connectionString );
190 
192  virtual void close();
193 
197  bool checkSignature(std::istream& str);
198 
210 
211 protected:
212 
219  bool open( std::shared_ptr<ossim::istream>& str );
220 
225  bool readPngInit();
226 
231  bool initReader();
232 
233  void readPngVersionInfo();
235 
239  void setMaxPixelValue();
240 
249  virtual bool open();
250 
255  void allocate();
256 
261  void destroy();
262 
268  void restart();
269 
274  void fillTile(const ossimIrect& clip_rect, ossimImageData* tile);
275 
276  template <class T> void copyLines(T dummy, ossim_uint32 stopLine);
277  template <class T> void copyLinesWithAlpha(T, ossim_uint32 stopLine);
278 
284  static void pngReadData(
285  png_structp png_ptr, png_bytep data, png_size_t length);
286 
289 
292 
293  std::shared_ptr<ossim::istream> m_str;
294 
301 
302 
304 
305  png_structp m_pngReadPtr;
306  png_infop m_pngReadInfoPtr;
308  ossim_uint32 m_currentRow; // 0 at start or first line
313 
314  std::vector<ossim_float64> m_maxPixelValue;
315 
317 
318  // If true the alpha channel will be passed on as a band.
320 
321 TYPE_DATA
322 };
323 
324 #endif /* #ifndef ossimPngReader_HEADER */
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
void fillTile(const ossimIrect &clip_rect, ossimImageData *tile)
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Get propterty method.
char ossim_int8
Previous DLL import export section.
void destroy()
Free tile and buffer memory.
bool isOpen() const
Derived classes must implement this method to be concrete.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
Returns a pointer to a tile given an origin representing the upper left corner of the tile to grab fr...
std::shared_ptr< ossim::istream > m_str
void allocate()
Initializes tiles and buffers.
ossimIrect m_imageRect
void copyLines(T dummy, ossim_uint32 stopLine)
Represents serializable keyword/value map.
virtual ossimIrect getImageRectangle(ossim_uint32 reduced_res_level=0) const
Returns the zero based image rectangle for the reduced resolution data set (rrds) passed in...
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Get propterty names.
ossimAppFixedTileCache::ossimAppFixedCacheId m_cacheId
ossim_uint8 * m_lineBuffer
bool initReader()
Initializes this reader from libpng m_pngPtr and infoPtr.
png_structp m_pngReadPtr
bool checkSignature(std::istream &str)
std::vector< ossim_float64 > m_maxPixelValue
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Set propterty method.
ossimRefPtr< ossimImageData > m_cacheTile
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossim_uint32 m_lineBufferSizeInBytes
virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level=0) const
Returns the number of lines in the image.
ossimString getPngColorTypeString() const
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
ossimPngReader()
default constructor
ossimPngReadMode m_readMode
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Gets the image geometry.
#define TYPE_DATA
Definition: ossimRtti.h:339
ossim_uint32 m_numberOfInputBands
unsigned int ossim_uint32
virtual ossim_uint32 getTileHeight() const
Returns the height of the output tile.
void copyLinesWithAlpha(T, ossim_uint32 stopLine)
bool m_useAlphaChannelFlag
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
ossimIrect m_bufferRect
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
ossim_int8 m_bitDepth
ossim_int8 m_pngColorType
ossimScalarType
virtual ossimString getShortName() const
virtual ~ossimPngReader()
virtual destructor
void setMaxPixelValue()
the max pixel value.
virtual ossimString getLongName() const
virtual ossimString getClassName() const
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossim_uint32 m_bytePerPixelPerBand
ossim_uint32 m_numberOfOutputBands
This class defines an abstract Handler which all image handlers(loaders) should derive from...
ossimIpt m_cacheSize
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
ossimRefPtr< ossimImageData > m_tile
virtual void close()
Close method.
void restart()
Method to restart reading from the beginning (for backing up).
virtual ossim_uint32 getTileWidth() const
Returns the width of the output tile.
virtual bool open()
open method.
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
ossim_int32 m_interlacePasses
ossim_uint32 m_currentRow
static void pngReadData(png_structp png_ptr, png_bytep data, png_size_t length)
Callback method for reading from a stream.
unsigned char ossim_uint8
png_infop m_pngReadInfoPtr
ossimScalarType m_outputScalarType
int ossim_int32
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 reduced_res_level=0) const
Returns the number of samples in the image.
bool readPngInit()
Performs signature check and initializes png_structp and png_infop.