OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimKakaduJ2kReader.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 // Description:
8 //
9 // Class declaration for JPEG2000 (J2K) reader.
10 //
11 //----------------------------------------------------------------------------
12 // $Id: ossimKakaduJ2kReader.h 22884 2014-09-12 13:14:35Z dburken $
13 
14 #ifndef ossimKakaduJ2kReader_HEADER
15 #define ossimKakaduJ2kReader_HEADER 1
16 
18 #include <ossim/base/ossimIrect.h>
22 #include <iosfwd>
23 #include <fstream>
24 
25 // Forward class declarations.
26 class ossimImageData;
27 
28 //---
29 // Kakadu put multiple classes in header: kdu_compressed_source, kd_thread_env
30 //---
31 #include <kdu_compressed.h>
32 // #include <kdu_region_decompressor.h>
33 
34 namespace kdu_core
35 {
36  class kdu_line_buf;
37  class kdu_thread_queue;
38 }
39 
45  public ossimImageHandler, public kdu_core::kdu_compressed_source
46 {
47 public:
48 
51 
53  virtual ~ossimKakaduJ2kReader();
54 
59  virtual ossimString getShortName() const;
60 
65  virtual ossimString getLongName() const;
66 
71  virtual ossimString getClassName() const;
72 
83  ossim_uint32 resLevel=0);
84 
89  virtual ossim_uint32 getNumberOfInputBands() const;
90 
96  virtual ossim_uint32 getNumberOfOutputBands()const;
103  virtual ossim_uint32 getImageTileWidth() const;
104 
111  virtual ossim_uint32 getImageTileHeight() const;
112 
116  virtual ossimScalarType getOutputScalarType() const;
117 
123  virtual void getDecimationFactor(ossim_uint32 resLevel,
124  ossimDpt& result) const;
125 
130  virtual void getDecimationFactors(vector<ossimDpt>& decimations) const;
131 
142 
153  virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel = 0) const;
154 
165  virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel = 0) const;
166 
171  virtual bool open();
172 
178  virtual bool isOpen()const;
179 
187  virtual void closeEntry();
188 
193  virtual bool loadState(const ossimKeywordlist& kwl,
194  const char* prefix=0);
195 
196 protected:
197 
216  virtual bool getOverviewTile(ossim_uint32 resLevel,
217  ossimImageData* result);
218 
226  virtual ossim_int32 get_capabilities();
227 
238  virtual ossim_int32 read(kdu_core::kdu_byte *buf, ossim_int32 num_bytes);
239 
249  virtual bool seek(kdu_core::kdu_long offset);
250 
258  virtual kdu_core::kdu_long get_pos();
259 
260 private:
261 
263  void initializeTile();
264 
279  bool loadTileFromCache(ossim_uint32 x, ossim_uint32 y,
280  const ossimIrect& clipRect);
281 
294  bool loadTile(ossim_uint32 x, ossim_uint32 y);
295 
296  kdu_core::kdu_codestream theCodestream;
297  kdu_core::kdu_thread_env* theThreadEnv;
298  kdu_core::kdu_thread_queue* theOpenTileThreadQueue;
309 
310 
312 
313 TYPE_DATA
314 };
315 
317 {
318  return ( KDU_SOURCE_CAP_SEEKABLE );
319 }
320 
321 inline ossim_int32 ossimKakaduJ2kReader::read(kdu_core::kdu_byte *buf,
322  ossim_int32 num_bytes)
323 {
324  theFileStr.read((char*)buf, num_bytes);
325  return theFileStr.gcount();
326 }
327 
328 inline bool ossimKakaduJ2kReader::seek(kdu_core::kdu_long offset)
329 {
330  // If the last byte is read, the eofbit must be reset.
331  if ( theFileStr.eof() )
332  {
333  theFileStr.clear();
334  }
335 
336  //---
337  // All seeks are relative to the start of code stream.
338  //---
339  theFileStr.seekg(offset, ios_base::beg);
340 
341  return theFileStr.good();
342 }
343 
344 inline kdu_core::kdu_long ossimKakaduJ2kReader::get_pos()
345 {
346  //---
347  // Must subtract the SOC(start of code stream) from the real file position
348  // since positions are relative to SOC.
349  //---
350  return static_cast<kdu_core::kdu_long>(theFileStr.tellg());
351 }
352 
353 #endif /* #ifndef ossimKakaduJ2kReader_HEADER */
virtual bool open()=0
Pure virtual open.
ossim_uint32 x
ossim_uint32 theSourcePrecisionBits
virtual void getDecimationFactors(vector< ossimDpt > &decimations) const
This returns all decimation for all levels.
virtual kdu_core::kdu_long get_pos()
Get file position relative to the start of code stream offset.
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::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
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< ossimImageData > theCacheTile
virtual bool seek(kdu_core::kdu_long offset)
Seek method.
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
ossimKakaduJ2kReader class for reading images with JPEG2000 (J2K) compressed blocks using kakadu libr...
virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt &result) const
virtual ossimString getShortName() const
Definition: ossimObject.cpp:48
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
virtual bool isOpen() const =0
Derived classes must implement this method to be concrete.
kdu_core::kdu_codestream theCodestream
kdu_core::kdu_thread_queue * theOpenTileThreadQueue
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
virtual ossim_int32 read(kdu_core::kdu_byte *buf, ossim_int32 num_bytes)
Read method.
#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 ossimString getLongName() const
Definition: ossimObject.cpp:53
#define OSSIM_PLUGINS_DLL
ossimScalarType
ossimScalarType theScalarType
virtual ossim_uint32 getImageTileWidth() const =0
Returns the tile width of the image or 0 if the image is not tiled.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageData > theTile
This class defines an abstract Handler which all image handlers(loaders) should derive from...
kdu_core::kdu_thread_env * theThreadEnv
ossimAppFixedTileCache::ossimAppFixedCacheId theCacheId
ossimJ2kSizRecord theSizRecord
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual ossim_int32 get_capabilities()
Gets kdu source capability.
virtual ossim_uint32 getNumberOfInputBands() const =0
int ossim_int32
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)