OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfTileSource.h
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description:
10 //
11 // Contains class declaration for NitfTileSource.
12 //
13 //---
14 // $Id$
15 
16 #ifndef ossimNitfTileSource_HEADER
17 #define ossimNitfTileSource_HEADER 1
18 
25 #include <memory>
26 
27 struct jpeg_decompress_struct;
28 
30 {
31 public:
32 
33  enum ReadMode
34  {
35  READ_MODE_UNKNOWN = 0,
36 
38  READ_BIB_BLOCK = 1,
39 
41  READ_BIP_BLOCK = 2,
42 
44  READ_BIR_BLOCK = 3,
45 
47  READ_BSQ_BLOCK = 4,
48 
50  READ_BIB = 5,
51 
53  READ_BIP = 6,
54 
56  READ_BIR = 7,
57 
59  READ_JPEG_BLOCK = 8
60  };
61 
63 
64 
65  virtual ossimString getShortName() const;
66  virtual ossimString getLongName() const;
67 
71  virtual bool open();
72 
80  bool open( std::shared_ptr<ossim::istream>& str,
81  const std::string& connectionString );
82 
84  virtual void close();
85 
97  virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tileRect,
98  ossim_uint32 resLevel=0);
99 
104  virtual ossim_uint32 getNumberOfInputBands() const;
105 
109  virtual ossim_uint32 getNumberOfOutputBands() const;
110 
115  virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel = 0) const;
116 
121  virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel = 0) const;
122 
127  virtual bool saveState(ossimKeywordlist& kwl,
128  const char* prefix=0)const;
129 
134  virtual bool loadState(const ossimKeywordlist& kwl,
135  const char* prefix=0);
136 
140  virtual ossimScalarType getOutputScalarType() const;
141 
145  virtual ossim_uint32 getTileWidth() const;
146 
150  virtual ossim_uint32 getTileHeight() const;
151 
158  virtual ossim_uint32 getImageTileWidth() const;
159 
166  virtual ossim_uint32 getImageTileHeight() const;
167 
168  virtual bool isOpen()const;
169 
176  virtual ossim_uint32 getCurrentEntry() const;
177 
181  virtual void getEntryList(std::vector<ossim_uint32>& entryList) const;
182 
188 
195  virtual bool setCurrentEntry(ossim_uint32 entryIdx);
196 
197  virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
198  virtual void setProperty(ossimRefPtr<ossimProperty> property);
199  virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
200 
201  ossimString getSecurityClassification()const;
202 
206  bool getCacheEnabledFlag() const;
207 
213  void setCacheEnabledFlag(bool flag);
214 
215  virtual double getMinPixelValue(ossim_uint32 band=0)const;
216  virtual double getMaxPixelValue(ossim_uint32 band=0)const;
217  virtual double getNullPixelValue(ossim_uint32 band=0)const;
218 
219  const ossimNitfFileHeader* getFileHeader()const;
220  ossimNitfFileHeader* getFileHeader();
224  const ossimNitfImageHeader* getCurrentImageHeader() const;
225  ossimNitfImageHeader* getCurrentImageHeader();
226 
236  virtual bool getRgbBandList(std::vector<ossim_uint32>& bandList) const;
237 
238 protected:
239  virtual ~ossimNitfTileSource();
240 
246  void setBoundingRectangle(const ossimIrect& imageRect);
247 
250 
253 
257  bool loadTile(const ossimIrect& clipRect);
258 
262  ossim_uint32 getBlockNumber(const ossimIpt& block_origin) const;
263 
267  void destroy();
268 
273  virtual bool parseFile();
274 
287  virtual bool allocate();
288 
296  virtual bool allocateBuffers();
297 
302  virtual bool canUncompress(const ossimNitfImageHeader* hdr) const;
303 
307  virtual void initializeScalarType();
308 
312  virtual void initializeSwapBytesFlag();
313 
317  virtual void initializeReadMode();
318 
322  void initializeBandCount();
323 
335  bool initializeBlockSize();
336 
343  virtual bool initializeImageRect();
344 
348  void initializeCacheSize();
349 
353  virtual void initializeCacheTileInterLeaveType();
354 
360  void initializeCacheTile();
361 
365  virtual void initializeCompressedBuf();
366 
370  virtual void initializeOutputTile();
371 
375  void initializeLut();
376 
389  bool loadBlockFromCache(ossim_uint32 x, ossim_uint32 y,
390  const ossimIrect& clipRect);
391 
404  virtual bool loadBlock(ossim_uint32 x, ossim_uint32 y);
405 
416  bool getPosition(std::streamoff& position,
417  ossim_uint32 x,
418  ossim_uint32 y,
419  ossim_uint32 band) const;
420 
426  ossim_uint32 getNumberOfBlocks() const;
427 
431  std::streampos getBandOffset() const;
432 
436  std::streampos getBlockOffset() const;
437 
438 
439  void explodePackedBits(ossimRefPtr<ossimImageData> packedBuffer)const;
440 
441  void convertTransparentToNull(ossimRefPtr<ossimImageData> tile)const;
442 
443  ossim_uint32 getPartialReadSize(const ossimIpt& blockOrigin)const;
444  bool isVqCompressed(const ossimString& compressionCode)const;
445 
452  void vqUncompressC4(ossimRefPtr<ossimImageData> destination,
453  ossim_uint8* source);
454 
461  void vqUncompressM4(ossimRefPtr<ossimImageData> destination,
462  ossim_uint8* source);
463 
464  void lutUncompress(ossimRefPtr<ossimImageData> destination,
465  ossim_uint8* source);
466 
473  virtual bool scanForJpegBlockOffsets();
474 
483  virtual bool uncompressJpegBlock(ossim_uint32 x, ossim_uint32 y);
484 
496  bool loadJpegQuantizationTables(jpeg_decompress_struct& cinfo) const;
497 
503  bool loadJpegHuffmanTables(jpeg_decompress_struct& cinfo) const;
504 
509  virtual void establishDecimationFactors();
510 
514  std::vector<ossimRefPtr<ossimNitfImageHeader> > theNitfImageHeader;
525  std::shared_ptr<ossim::istream> theFileStr;
526  std::vector<ossim_uint32> theSelectorBandList;
527  std::vector<ossim_uint32> theOutputBandList;
531  std::vector<ossim_uint32> theEntryList;
535  std::vector<ossim_uint8> theCompressedBuf;
536 
537  //---
538  // Have compressed jpeg blocks of variable length so we must scan and
539  // capture the offsetts and block sizes for reading.
540  //---
541  std::vector<std::streamoff> theNitfBlockOffset;
542  std::vector<ossim_uint32> theNitfBlockSize;
543 
544  //---
545  // If set to true indicates scanForJpegBlockOffsets() needs to be called
546  // prior to grabbing a block.
547  //---
549 
550 TYPE_DATA
551 };
552 
553 #endif /* #ifndef ossimNitfTileSource_HEADER */
virtual bool open()=0
Pure virtual open.
ossim_uint32 x
std::vector< ossim_uint32 > theEntryList
ossim_uint32 theNumberOfInputBands
Represents serializable keyword/value map.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
ossim_uint32 y
std::shared_ptr< ossim::istream > theFileStr
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
ossimRefPtr< ossimNitfFile > theNitfFile
std::vector< ossim_uint32 > theNitfBlockSize
const ossimImageSource & operator=(const ossimImageSource &)
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
ossim_uint32 theReadBlockSizeInBytes
virtual void setProperty(ossimRefPtr< ossimProperty > property)
ossimInterleaveType theCacheTileInterLeaveType
std::vector< ossim_uint8 > theCompressedBuf
virtual ossimString getShortName() const
Definition: ossimObject.cpp:48
virtual ossim_uint32 getTileWidth() const
Returns the default processing tile width.
virtual bool isOpen() const =0
Derived classes must implement this method to be concrete.
virtual double getMinPixelValue(ossim_uint32 band=0) const
Retuns the min pixel value.
ossim_uint32 theBlockSizeInBytes
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
ossim_uint32 theNumberOfImages
#define TYPE_DATA
Definition: ossimRtti.h:339
virtual ossim_uint32 getImageTileHeight() const =0
Returns the tile width of the image or 0 if the image is not tiled.
unsigned int ossim_uint32
virtual bool getRgbBandList(std::vector< ossim_uint32 > &bandList) const
Convenience method to get the zero based rgb output band list.
ossimRefPtr< ossimImageData > theCacheTile
virtual ossimString getLongName() const
Definition: ossimObject.cpp:53
virtual void close()
Deletes the overview and clears the valid image vertices.
virtual ossim_uint32 getCurrentEntry() const
ossimInterleaveType
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
virtual ossim_uint32 getNumberOfEntries() const
virtual void getEntryList(std::vector< ossim_uint32 > &entryList) const
virtual void establishDecimationFactors()
Virtual method determines the decimation factors at each resolution level.
ossimScalarType
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossimScalarType theScalarType
virtual ossim_uint32 getImageTileWidth() const =0
Returns the tile width of the image or 0 if the image is not tiled.
ossimRefPtr< ossimImageData > theTile
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
#define OSSIM_DLL
std::vector< ossim_uint32 > theSelectorBandList
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
virtual ossim_uint32 getNumberOfInputBands() const =0
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
unsigned char ossim_uint8
std::vector< ossim_uint32 > theOutputBandList
std::vector< ossimRefPtr< ossimNitfImageHeader > > theNitfImageHeader
std::vector< std::streamoff > theNitfBlockOffset
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
ossim_uint32 theNumberOfOutputBands