root / trunk / libraries / libjni-mrsid / include / base / lti_pixel.h @ 720
History | View | Annotate | Download (10.2 KB)
1 |
/* $Id: lti_pixel.h 720 2004-12-28 16:18:01Z igbrotru $ */
|
---|---|
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 LTI_PIXEL_H
|
14 |
#define LTI_PIXEL_H
|
15 |
|
16 |
// lt_lib_mrsid_core
|
17 |
#include "lti_types.h" |
18 |
|
19 |
|
20 |
#if defined(LT_COMPILER_MS)
|
21 |
#pragma warning(push,4) |
22 |
#endif
|
23 |
|
24 |
LT_BEGIN_NAMESPACE(LizardTech) |
25 |
|
26 |
class LTISample; |
27 |
|
28 |
|
29 |
/**
|
30 |
* basic properties of a pixel
|
31 |
*
|
32 |
* This class stores the basic properties of a pixel:
|
33 |
* \li the number of bands
|
34 |
* \li the colorspace
|
35 |
* \li the datatype
|
36 |
*
|
37 |
* This is done by representing the pixel as a set of samples.
|
38 |
* Since the colorspace cannot in general be inferred from the
|
39 |
* colors in the samples, the user must declare the colorspace
|
40 |
* for the pixel.
|
41 |
*/
|
42 |
class LTIPixel |
43 |
{ |
44 |
public:
|
45 |
/**
|
46 |
* constructor
|
47 |
*
|
48 |
* This constructor creates an LTIPixel object with the given
|
49 |
* properties: all the samples will be of the same type.
|
50 |
*
|
51 |
* @param colorSpace the pixel colorspace
|
52 |
* @param numBands the number of bands (samples per pixel)
|
53 |
* @param dataType the datatype of the samples
|
54 |
* @param samples optional sample objects (default is uint8 set to 0)
|
55 |
*/
|
56 |
LTIPixel(LTIColorSpace colorSpace, |
57 |
lt_uint16 numBands, |
58 |
LTIDataType dataType, |
59 |
const LTISample* samples=0); |
60 |
|
61 |
/**
|
62 |
* constructor
|
63 |
*
|
64 |
* This constructor creates an LTIPixel object made up of the
|
65 |
* given sample types. If the colorspace given is LTI_COLORSPACE_INVALID,
|
66 |
* then the function will attempt to infer the colorspace from the
|
67 |
* underlying samples; if there is no obvious colorspace, e.g. RGB,
|
68 |
* the LTI_COLORSPACE_MULTISPECTRAL will be used.
|
69 |
*
|
70 |
* @param samples the samples of the pixel
|
71 |
* @param numBands the number of bands (samples per pixel)
|
72 |
* @param colorSpace the overall colorspace
|
73 |
*/
|
74 |
LTIPixel(const LTISample* samples,
|
75 |
lt_uint16 numBands, |
76 |
LTIColorSpace colorSpace=LTI_COLORSPACE_INVALID); |
77 |
|
78 |
/**
|
79 |
* copy constructor
|
80 |
*/
|
81 |
LTIPixel(const LTIPixel&);
|
82 |
|
83 |
/**
|
84 |
* destructor
|
85 |
*/
|
86 |
virtual ~LTIPixel(); |
87 |
|
88 |
/**
|
89 |
* assignment operator
|
90 |
*/
|
91 |
virtual LTIPixel& operator=(const LTIPixel&);
|
92 |
|
93 |
/**
|
94 |
* equality operator
|
95 |
*/
|
96 |
bool operator==(const LTIPixel&) const; |
97 |
|
98 |
/**
|
99 |
* equality operator
|
100 |
*/
|
101 |
bool operator!=(const LTIPixel&) const; |
102 |
|
103 |
/**
|
104 |
* get the sample datatype
|
105 |
*
|
106 |
* This function returns the datatype of the samples. Returns
|
107 |
* LTI_DATATYPE_INVALID if the samples are not all the same
|
108 |
* datatype.
|
109 |
*
|
110 |
* @return the datatype of the samples
|
111 |
*/
|
112 |
LTIDataType getDataType() const;
|
113 |
|
114 |
/**
|
115 |
* get the colorspace
|
116 |
*
|
117 |
* This function returns the colorspace of the pixel.
|
118 |
*
|
119 |
* @return the colorspace of the pixel
|
120 |
*/
|
121 |
LTIColorSpace getColorSpace() const;
|
122 |
|
123 |
/**
|
124 |
* get the number of bands
|
125 |
*
|
126 |
* This function returns the number of bands in the pixel (samples
|
127 |
* per pixel).
|
128 |
*
|
129 |
* @return the number of bands
|
130 |
*/
|
131 |
lt_uint16 getNumBands() const;
|
132 |
|
133 |
/**
|
134 |
* get the size of a pixel
|
135 |
*
|
136 |
* This function returns the size of a single pixel, in bytes.
|
137 |
*
|
138 |
* This is equivalent to the sum of getBytesPerSample() for each
|
139 |
* of the samples.
|
140 |
*
|
141 |
* @return the number of bytes per pixel
|
142 |
*/
|
143 |
lt_uint32 getNumBytes() const;
|
144 |
|
145 |
/**
|
146 |
* returns the largest size of any sample
|
147 |
*
|
148 |
* Returns the largest size of any sample. This is equivalent to the
|
149 |
* computing the maximum of getBytesPerSample() for each of the samples.
|
150 |
*
|
151 |
* @return the number of bytes per sample
|
152 |
*/
|
153 |
lt_uint32 getMaxBytesPerSample() const;
|
154 |
|
155 |
/**
|
156 |
* returns status code comparing two pixels
|
157 |
*
|
158 |
* Returns status code comparing two pixels. This is just a different
|
159 |
* version of operator==, which returns a status code instead of a bool.
|
160 |
*
|
161 |
* @param pixel the sample to compare this sample to
|
162 |
* @return a specific code indicating if impedance matches
|
163 |
*/
|
164 |
LT_STATUS checkImpedance(const LTIPixel& pixel) const; |
165 |
|
166 |
/**
|
167 |
* returns status code indicating if supported SDK type
|
168 |
*
|
169 |
* Returns status code indicating if this pixel type is one of the
|
170 |
* normally supported SDK types, e.g. uint8/uint16, gray/RGB/CMYK, etc.
|
171 |
*
|
172 |
* @return a specific code indicating if pixel type supported
|
173 |
*/
|
174 |
LT_STATUS checkSupported() const;
|
175 |
|
176 |
LTISample* getSamples() const;
|
177 |
LTISample& getSample(lt_uint16) const;
|
178 |
|
179 |
/**
|
180 |
* @name Helper functions to get sample values
|
181 |
*/
|
182 |
/*@{*/
|
183 |
|
184 |
/**
|
185 |
* returns the address of the specified sample's value
|
186 |
*
|
187 |
* Returns the address of the specified sample's value. The caller must
|
188 |
* cast the pointer to the appropriate type before using.
|
189 |
*
|
190 |
* @param band the band number of the sample to use
|
191 |
* @return the address of the sample's value
|
192 |
*/
|
193 |
const void* getSampleValueAddr(lt_uint16 band) const; |
194 |
|
195 |
/**
|
196 |
* returns the specified sample's value
|
197 |
*
|
198 |
* Returns the specified sample's value. The sample is assumed to be
|
199 |
* known to have the UINT8 datatype.
|
200 |
*
|
201 |
* @param band the band number of the sample to use
|
202 |
* @return the sample's value
|
203 |
*/
|
204 |
lt_uint8 getSampleValueUint8(lt_uint16 band) const;
|
205 |
|
206 |
/**
|
207 |
* returns the specified sample's value
|
208 |
*
|
209 |
* Returns the specified sample's value. The sample is assumed to be
|
210 |
* known to have the UINT16 datatype.
|
211 |
*
|
212 |
* @param band the band number of the sample to use
|
213 |
* @return the sample's value
|
214 |
*/
|
215 |
lt_uint16 getSampleValueUint16(lt_uint16 band) const;
|
216 |
|
217 |
/**
|
218 |
* returns the specified sample's value
|
219 |
*
|
220 |
* Returns the specified sample's value. The sample is assumed to be
|
221 |
* known to have the FLOAT32 datatype.
|
222 |
*
|
223 |
* @param band the band number of the sample to use
|
224 |
* @return the sample's value
|
225 |
*/
|
226 |
float getSampleValueFloat32(lt_uint16 band) const; |
227 |
|
228 |
/*@}*/
|
229 |
|
230 |
/**
|
231 |
* @name Helper functions to set sample values
|
232 |
*/
|
233 |
/*@{*/
|
234 |
|
235 |
/**
|
236 |
* sets all samples to minimum
|
237 |
*
|
238 |
* Sets all samples to the minimum value of the datatype.
|
239 |
*/
|
240 |
void setSampleValuesToMin();
|
241 |
|
242 |
/**
|
243 |
* sets all samples to maximum
|
244 |
*
|
245 |
* Sets all samples to the maximum value of the datatype.
|
246 |
*/
|
247 |
void setSampleValuesToMax();
|
248 |
|
249 |
/**
|
250 |
* sets sample value by address
|
251 |
*
|
252 |
* Sets sample value to value pointed to.
|
253 |
*
|
254 |
* @param band which sample to set
|
255 |
* @param data value to use
|
256 |
*/
|
257 |
void setSampleValueAddr(lt_uint16 band, const void* data) const; |
258 |
|
259 |
/**
|
260 |
* sets all samples to the given value
|
261 |
*
|
262 |
* Sets all samples to the given value of the datatype. The samples are
|
263 |
* assumed to be known to have the UINT8 datatype.
|
264 |
*
|
265 |
* @param value the value to set the samples to
|
266 |
*/
|
267 |
void setSampleValuesUint8(lt_uint8 value);
|
268 |
|
269 |
/**
|
270 |
* sets all samples to the given value
|
271 |
*
|
272 |
* Sets all samples to the given value of the datatype. The samples are
|
273 |
* assumed to be known to have the UINT16 datatype.
|
274 |
*
|
275 |
* @param value the value to set the samples to
|
276 |
*/
|
277 |
void setSampleValuesUint16(lt_uint16 value);
|
278 |
|
279 |
/**
|
280 |
* sets all samples to the given value
|
281 |
*
|
282 |
* Sets all samples to the given value of the datatype. The samples are
|
283 |
* assumed to be known to have the FLOAT32 datatype.
|
284 |
*
|
285 |
* @param value the value to set the samples to
|
286 |
*/
|
287 |
void setSampleValuesFloat32(float value); |
288 |
|
289 |
/**
|
290 |
* sets the given sample to the given value
|
291 |
*
|
292 |
* Sets the given sample to the given value of the datatype. The sample is
|
293 |
* assumed to be known to have the UINT8 datatype.
|
294 |
*
|
295 |
* @param band the band number of the sample to use
|
296 |
* @param value the value to set the samples to
|
297 |
*/
|
298 |
void setSampleValueUint8(lt_uint16 band, lt_uint8 value);
|
299 |
|
300 |
/**
|
301 |
* sets the given sample to the given value
|
302 |
*
|
303 |
* Sets the given sample to the given value of the datatype. The sample is
|
304 |
* assumed to be known to have the UINT16 datatype.
|
305 |
*
|
306 |
* @param band the band number of the sample to use
|
307 |
* @param value the value to set the samples to
|
308 |
*/
|
309 |
void setSampleValueUint16(lt_uint16 band, lt_uint16 value);
|
310 |
|
311 |
/**
|
312 |
* sets the given sample to the given value
|
313 |
*
|
314 |
* Sets the given sample to the given value of the datatype. The sample is
|
315 |
* assumed to be known to have the FLOAT32 datatype.
|
316 |
*
|
317 |
* @param band the band number of the sample to use
|
318 |
* @param value the value to set the samples to
|
319 |
*/
|
320 |
void setSampleValueFloat32(lt_uint16 band, float value); |
321 |
|
322 |
/**
|
323 |
* sets all samples to the given values
|
324 |
*
|
325 |
* Sets all samples to the given values of the datatype. The sample is
|
326 |
* assumed to be known to have the UINT8 datatype.
|
327 |
*
|
328 |
* @param values the values to set the samples to
|
329 |
*/
|
330 |
void setSampleValuesUint8(const lt_uint8* values); |
331 |
|
332 |
/**
|
333 |
* sets all samples to the given values
|
334 |
*
|
335 |
* Sets all samples to the given values of the datatype. The sample is
|
336 |
* assumed to be known to have the UINT16 datatype.
|
337 |
*
|
338 |
* @param values the values to set the samples to
|
339 |
*/
|
340 |
void setSampleValuesUint16(const lt_uint16* values); |
341 |
|
342 |
/**
|
343 |
* sets all samples to the given values
|
344 |
*
|
345 |
* Sets all samples to the given values of the datatype. The sample is
|
346 |
* assumed to be known to have the FLOAT32 datatype.
|
347 |
*
|
348 |
* @param values the values to set the samples to
|
349 |
*/
|
350 |
void setSampleValuesFloat32(const float* values); |
351 |
/*@}*/
|
352 |
|
353 |
private:
|
354 |
void createSamples(LTIDataType dt);
|
355 |
void createSamples(const LTISample*); |
356 |
void deleteSamples();
|
357 |
|
358 |
LTISample* m_samples; |
359 |
lt_uint16 m_numBands; |
360 |
LTIColorSpace m_colorSpace; |
361 |
}; |
362 |
|
363 |
|
364 |
LT_END_NAMESPACE(LizardTech) |
365 |
|
366 |
#if defined(LT_COMPILER_MS)
|
367 |
#pragma warning(pop)
|
368 |
#endif
|
369 |
|
370 |
#endif // LTI_PIXEL_H |