svn-gvsig-desktop / trunk / libraries / libjni-mrsid-macosx / include / j2k_readers / J2KImageReader.h @ 9099
History | View | Annotate | Download (7.95 KB)
1 |
/* $Id: J2KImageReader.h 9099 2006-11-29 12:16:22Z mija $ */
|
---|---|
2 |
/* //////////////////////////////////////////////////////////////////////////
|
3 |
// //
|
4 |
// This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue, //
|
5 |
// Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
|
6 |
// prohibited. Access to and use of this code is permitted only under //
|
7 |
// license from LizardTech, Inc. Portions of the code are protected by //
|
8 |
// US and foreign patents and other filings. All Rights Reserved. //
|
9 |
// //
|
10 |
////////////////////////////////////////////////////////////////////////// */
|
11 |
/* PUBLIC */
|
12 |
|
13 |
#ifndef J2KIMAGEREADER_H
|
14 |
#define J2KIMAGEREADER_H
|
15 |
|
16 |
// lt_lib_mrsid_core
|
17 |
#include "lti_imageReader.h" |
18 |
|
19 |
// lt_lib_mrsid_j2k
|
20 |
#include "j2k_types.h" |
21 |
|
22 |
#if defined(LT_COMPILER_MS)
|
23 |
#pragma warning(push,4) |
24 |
#endif
|
25 |
|
26 |
|
27 |
LT_BEGIN_NAMESPACE(LizardTech) |
28 |
|
29 |
class LTFileSpec; |
30 |
class LTIOStreamInf; |
31 |
class J2KImageReaderImp; |
32 |
|
33 |
/**
|
34 |
* image reader for JPEG 2000 images
|
35 |
*
|
36 |
* This class provides support for reading JPEG 2000 images.
|
37 |
*
|
38 |
* @note Not all JP2/Part 1 images are supported yet. See the release
|
39 |
* notes for details.
|
40 |
*/
|
41 |
class J2KImageReader : public LTIImageReader |
42 |
{ |
43 |
public:
|
44 |
/**
|
45 |
* constructor
|
46 |
*
|
47 |
* Create a JPEG 2000 image reader from a file.
|
48 |
*
|
49 |
* The \a isPersistent parameter is used as a performance hint
|
50 |
* to the underlying codec. If you intend to do only one decode
|
51 |
* request from the image, you may set this value to false; this
|
52 |
* may result in improved memory usage and performance. If multiple
|
53 |
* decode requests are to be made, the value must be set to true.
|
54 |
*
|
55 |
* The \a maxBpp parameter controls the number of bits per sample
|
56 |
* to decode from. Values smaller than the number of bits per
|
57 |
* sample will produce lossy images, but generally the decode
|
58 |
* operations will be faster. A value of -1.0 indicates all
|
59 |
* available bits are to be used.
|
60 |
*
|
61 |
* @param fileSpec file to read from
|
62 |
* @param isPersistent set to true, unless only doing one decode request
|
63 |
* @param maxBpp set to number of bits per sample desired (or -1.0f for all bits)
|
64 |
*/
|
65 |
J2KImageReader(const LTFileSpec& fileSpec,
|
66 |
bool isPersistent = true, |
67 |
float maxBpp = -1.0f); |
68 |
|
69 |
/**
|
70 |
* constructor
|
71 |
*
|
72 |
* Create a JPEG 2000 image reader from a stream.
|
73 |
*
|
74 |
* See file constructor for parameter descriptions.
|
75 |
*
|
76 |
* @param stream stream to read from
|
77 |
* @param isPersistent set to true, unless only doing one decode request
|
78 |
* @param maxBpp set to number of bits per sample desired (or -1.0f for all bits)
|
79 |
*/
|
80 |
J2KImageReader(LTIOStreamInf &stream, |
81 |
bool isPersistent = true, |
82 |
float maxBpp = -1.0f); |
83 |
|
84 |
/**
|
85 |
* destructor
|
86 |
*/
|
87 |
virtual ~J2KImageReader(); |
88 |
|
89 |
LT_STATUS initialize(); |
90 |
|
91 |
/**
|
92 |
* @name precision control
|
93 |
*/
|
94 |
/*@{*/
|
95 |
|
96 |
/**
|
97 |
* control decoder use of bits of precision
|
98 |
*
|
99 |
* These functions allow the caller to control the number of bits of
|
100 |
* precision (or bits per sample) used in satisfying the decode request.
|
101 |
*
|
102 |
* The default is to use all available bits.
|
103 |
*
|
104 |
* Note this allows for precision control on a per-decode basis. The
|
105 |
* \a maxBpp constructor parameter performs a similar function, but
|
106 |
* sets the value for all decode operations on the image.
|
107 |
*/
|
108 |
LT_STATUS setParameter_Precision(lt_uint32 precision); |
109 |
lt_uint32 getParameter_Precision() const;
|
110 |
lt_uint32 getParameter_MinPrecision() const;
|
111 |
lt_uint32 getParameter_MaxPrecision() const;
|
112 |
lt_uint32 getParameter_DefaultPrecision() const;
|
113 |
/*@}*/
|
114 |
|
115 |
/**
|
116 |
* @name quality layer control
|
117 |
*/
|
118 |
/*@{*/
|
119 |
|
120 |
/**
|
121 |
* control decoder use of quality layers
|
122 |
*
|
123 |
* These functions allow the caller to control the number of quality
|
124 |
* layers used in satisfying the decode request. Use of quality
|
125 |
* layers allow for "preset" compression ratios to be encoded into
|
126 |
* the image.
|
127 |
*
|
128 |
* The default is to use all available layers).
|
129 |
*/
|
130 |
LT_STATUS setParameter_Layers(lt_uint32 numLayers); |
131 |
lt_uint32 getParameter_Layers() const;
|
132 |
lt_uint32 getParameter_MinLayers() const;
|
133 |
lt_uint32 getParameter_MaxLayers() const;
|
134 |
lt_uint32 getParameter_DefaultLayers() const;
|
135 |
/*@}*/
|
136 |
|
137 |
/**
|
138 |
* get image tile size
|
139 |
*
|
140 |
* Returns the size of the tile(s) used to encode the image, in pixels.
|
141 |
* An image that is "not tiled" is considered to be encoded as one
|
142 |
* large tile, the size of the entire image.
|
143 |
*
|
144 |
* @param width tile width, in pixels
|
145 |
* @param height tile height, in pixels
|
146 |
*/
|
147 |
void getParameter_TileSize(int& width, int& height) const; |
148 |
|
149 |
/**
|
150 |
* get image precinct sizes
|
151 |
*
|
152 |
* Returns the size of the precinct(s) used to encode the image, in pixels.
|
153 |
* The data is returned as pointers to arrays, one width/height value for
|
154 |
* each of the \a numPrecincts precincts.
|
155 |
*
|
156 |
* @param widths returned array of precincts widths, in pixels
|
157 |
* @param heights returned array of precincts heights, in pixels
|
158 |
* @param numPrecincts number of precincts in image (and length of \a widths / \a heights arrays)
|
159 |
*/
|
160 |
void getParameter_Precincts(const int*& widths, const int*& heights, int& numPrecincts) const; |
161 |
|
162 |
/**
|
163 |
* get image progression order
|
164 |
*
|
165 |
* Returns the progression order of the image.
|
166 |
*
|
167 |
* @return the progression order
|
168 |
*/
|
169 |
J2KProgressionOrder getParameter_ProgressionOrder() const;
|
170 |
|
171 |
/**
|
172 |
* get image codeblock size
|
173 |
*
|
174 |
* Returns the size of the codeblock used to encode the image, in pixels.
|
175 |
*
|
176 |
* @param width codeblock width, in pixels
|
177 |
* @param height codeblock width, in pixels
|
178 |
*/
|
179 |
void getParameter_CodeblockSize(int& width, int& height) const; |
180 |
|
181 |
/**
|
182 |
* query if 9-7 wavelet used
|
183 |
*
|
184 |
* Returns true if the image was encoded with the 9-7 wavelet. The 9-7
|
185 |
* wavelet may give better image quality as compared to the 5-3 wavelet
|
186 |
* for a given compression ratio, however the 9-7 wavelet does not support
|
187 |
* lossless encoding.
|
188 |
*
|
189 |
* @return true, if the 9-7 wavelet was used
|
190 |
*/
|
191 |
bool getParameter_Wavelet97() const; |
192 |
|
193 |
/**
|
194 |
* get number of resolution levels
|
195 |
*
|
196 |
* Returns the number of wavelet resolution levels encoded in the image.
|
197 |
* This is equivalent to the minimum magnification value, expressed
|
198 |
* as a power of two.
|
199 |
*
|
200 |
* @return the number of resolution levels
|
201 |
*/
|
202 |
lt_uint8 getNumLevels() const;
|
203 |
|
204 |
/**
|
205 |
* get metadata chunk
|
206 |
*
|
207 |
* This function is used to access the contents of a metadata box
|
208 |
* in the JPEG 2000 image, given a UUID. The box contents are
|
209 |
* copied into a user-supplied stream.
|
210 |
*
|
211 |
* @param uuid the UUID of the box to read
|
212 |
* @param stream stream to receive the metadata
|
213 |
* @return success or failure status code
|
214 |
*/
|
215 |
LT_STATUS readMetadataBox(const lt_uint8* uuid, LTIOStreamInf& stream);
|
216 |
|
217 |
/**
|
218 |
* control ownership of underlying stream
|
219 |
*
|
220 |
* This function is used to change the ownership of the image stream.
|
221 |
*
|
222 |
* @param takeOwnership set to true to have object own the stream
|
223 |
*/
|
224 |
void setStreamOwnership(bool takeOwnership); |
225 |
|
226 |
|
227 |
// overrides
|
228 |
lt_int64 getPhysicalFileSize() const;
|
229 |
const LTFileSpec& getFileSpec() const; |
230 |
|
231 |
protected:
|
232 |
friend class J2KImageReaderImp; |
233 |
|
234 |
// decode functions
|
235 |
LT_STATUS decodeBegin(const LTIScene& scene);
|
236 |
LT_STATUS decodeStrip(LTISceneBuffer& stripBuffer, |
237 |
const LTIScene& stripScene);
|
238 |
LT_STATUS decodeEnd(); |
239 |
|
240 |
private:
|
241 |
|
242 |
const LTFileSpec* m_ctor_fileSpec;
|
243 |
LTIOStreamInf* m_ctor_stream; |
244 |
const bool m_ctor_isPersistent; |
245 |
const float m_ctor_maxBpp; |
246 |
|
247 |
J2KImageReaderImp* m_imp; |
248 |
|
249 |
// nope
|
250 |
J2KImageReader(J2KImageReader&); |
251 |
J2KImageReader& operator=(const J2KImageReader&);
|
252 |
}; |
253 |
|
254 |
|
255 |
LT_END_NAMESPACE(LizardTech) |
256 |
|
257 |
#if defined(LT_COMPILER_MS)
|
258 |
#pragma warning(pop)
|
259 |
#endif
|
260 |
|
261 |
#endif // J2KIMAGEREADER_H |