OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimOpjCompressor.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: Wrapper class to compress whole tiles using OpenJPEG code.
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
12 #ifndef ossimOpjCompressor_HEADER
13 #define ossimOpjCompressor_HEADER 1
14 
16 #include <ossim/base/ossimIrect.h>
18 #include <ossim/base/ossimRefPtr.h>
19 #include <ossim/base/ossimString.h>
20 #include <opj_config.h>
21 #include <openjpeg.h>
22 #include <iosfwd>
23 
24 class ossimFilename;
25 class ossimImageData;
26 class ossimImageGeometry;
27 class ossimIpt;
28 
30 {
31 public:
32 
33  // Matches static "COMPRESSION_QUALITY" string array in .cpp.
35  {
41  };
42 
45 
48 
59  void create(std::ostream* os,
60  ossimScalarType scalar,
61  ossim_uint32 bands,
62  const ossimIrect& imageRect,
63  const ossimIpt& tileSize,
64  bool jp2);
65 
71  void openJp2Codestream();
72 
83  bool writeTile(ossimImageData* srcTile, ossim_uint32 tileIndex);
84 
89  void finish();
90 
96 
99 
108  void setReversibleFlag(bool reversible);
109 
111  bool getReversibleFlag() const;
112 
118  void setAlphaChannelFlag( bool flag );
119 
126  bool getAlphaChannelFlag() const;
127 
136  void setLevels(ossim_int32 levels);
137 
139  ossim_int32 getLevels() const;
140 
148  void setThreads(ossim_int32 threads);
149 
151  ossim_int32 getThreads() const;
152 
161  void setOptions(const std::vector<ossimString>& options);
162 
167  void getOptions(std::vector<ossimString>& options) const;
168 
172  bool saveState(ossimKeywordlist& kwl, const char* prefix=0)const;
173 
178  bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
179 
189 
196 
202  void getPropertyNames(std::vector<ossimString>& propertyNames)const;
203 
212  bool writeGeotiffBox(std::ostream* stream,
213  const ossimImageGeometry* geom,
214  const ossimIrect& rect,
215  const ossimFilename& tmpFile,
216  ossimPixelType pixelType);
217 
224  bool writeGmlBox( std::ostream* stream,
225  const ossimImageGeometry* geom,
226  const ossimIrect& rect );
227 
228 private:
229 
230  void initOpjCodingParams( bool jp2,
231  const ossimIpt& tileSize,
232  const ossimIrect& imageRect );
233 
234  int getNumberOfLayers() const;
235 
237  void setQualityTypeString(const ossimString& s);
238 
248  void initLevels( const ossimIrect& imageRect );
249 
260  void setCodeBlockSize( ossim_int32 xSize, ossim_int32 ySize);
261 
276  void setProgressionOrder( OPJ_PROG_ORDER progressionOrder );
277 
278  void setTlmTileCount(ossim_uint32 tilesToWrite);
279 
280  opj_cparameters_t* createOpjCodingParameters(
281  bool jp2,
282  const ossimIpt& tileSize,
283  const ossimIrect& imageRect ) const;
284 
285  opj_codec_t* createOpjCodec( bool jp2 ) const;
286 
287  opj_stream_t* createOpjStream( std::ostream* os ) const;
288 
289  opj_image_t* createOpjImage( ossimScalarType scalar,
290  ossim_uint32 bands,
291  const ossimIrect& imageRect ) const;
292 
293  opj_cparameters_t* m_params;
294  opj_codec_t* m_codec;
295  opj_stream_t* m_stream;
296 
297  opj_image_t* m_image;
298 
299 
300  // opj_codec* m_stream;
301  // opj_image_t* m_image = 0;
302 
303 
306 
309 
311  bool m_alpha;
312 
315 
318 
320  std::vector<ossimString> m_options;
321 
323 
324 };
325 
326 #endif /* matches: #ifndef ossimOpjCompressor_HEADER */
327 
~ossimOpjCompressor()
destructor
opj_cparameters_t * createOpjCodingParameters(bool jp2, const ossimIpt &tileSize, const ossimIrect &imageRect) const
bool setProperty(ossimRefPtr< ossimProperty > property)
Will set the property whose name matches the argument "property->getName()".
void finish()
Finish method.
bool writeGeotiffBox(std::ostream *stream, const ossimImageGeometry *geom, const ossimIrect &rect, const ossimFilename &tmpFile, ossimPixelType pixelType)
Writes the geotiff box to the jp2.
ossimOpjCompressionQuality m_qualityType
void create(std::ostream *os, ossimScalarType scalar, ossim_uint32 bands, const ossimIrect &imageRect, const ossimIpt &tileSize, bool jp2)
Create method.
Represents serializable keyword/value map.
void setProgressionOrder(OPJ_PROG_ORDER progressionOrder)
Sets progression order.
void setAlphaChannelFlag(bool flag)
Set the writer to add an alpha channel to the output png image.
opj_stream_t * m_stream
ossimOpjCompressor()
default constructor
bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
saves the state of the object.
ossim_int32 m_threads
Number of threads.
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
opj_stream_t * createOpjStream(std::ostream *os) const
void setOptions(const std::vector< ossimString > &options)
Sets the options array.
void setQualityType(ossimOpjCompressionQuality type)
Sets the quality type.
ossimOpjCompressionQuality getQualityType() const
void initOpjCodingParams(bool jp2, const ossimIpt &tileSize, const ossimIrect &imageRect)
void setThreads(ossim_int32 threads)
Sets the number of threads.
bool m_reversible
Lossless or lossy.
ossimIrect m_imageRect
Image rectangle.
void initLevels(const ossimIrect &imageRect)
Set levels, class attribute m_levels and m_parameters->numresolution.
unsigned int ossim_uint32
opj_image_t * createOpjImage(ossimScalarType scalar, ossim_uint32 bands, const ossimIrect &imageRect) const
void setReversibleFlag(bool reversible)
Sets the m_reversible flag.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ossimScalarType
void setLevels(ossim_int32 levels)
Sets the number of levels.
std::vector< ossimString > m_options
Container for Opj options.
ossimPixelType
ossim_int32 getThreads() const
ossim_int32 getLevels() const
bool getReversibleFlag() const
void setQualityTypeString(const ossimString &s)
bool m_alpha
If true write alpha channel.
ossimString getQualityTypeString() const
ossim_int32 m_levels
Reduced resolution levels.
opj_cparameters_t * m_params
opj_codec_t * createOpjCodec(bool jp2) const
bool writeGmlBox(std::ostream *stream, const ossimImageGeometry *geom, const ossimIrect &rect)
Writes the gml box to the jp2.
bool getAlphaChannelFlag() const
Retrieve the writer&#39;s setting for whether or not to add an alpha channel to the output png image...
void openJp2Codestream()
Calls "open_codestream" on the m_jp2Target.
void getOptions(std::vector< ossimString > &options) const
Get the array of options.
void setTlmTileCount(ossim_uint32 tilesToWrite)
bool writeTile(ossimImageData *srcTile, ossim_uint32 tileIndex)
Write tile method.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
void setCodeBlockSize(ossim_int32 xSize, ossim_int32 ySize)
Set code block size.
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Pushes this&#39;s names onto the list of property names.
int ossim_int32