svn-gvsig-desktop / trunk / libraries / libjni-mrsid / include / base / lti_scene.h @ 3539
History | View | Annotate | Download (13.4 KB)
1 |
/* $Id: lti_scene.h 3539 2006-01-09 12:23:20Z nacho $ */
|
---|---|
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_SCENE_H
|
14 |
#define LTI_SCENE_H
|
15 |
|
16 |
// lt_lib_base
|
17 |
#include "lt_base.h" |
18 |
|
19 |
|
20 |
#if defined(LT_COMPILER_MS)
|
21 |
#pragma warning(push,4) |
22 |
#endif
|
23 |
|
24 |
LT_BEGIN_NAMESPACE(LizardTech) |
25 |
|
26 |
|
27 |
/**
|
28 |
* representation of a scene
|
29 |
*
|
30 |
* This class represents a scene within an image. A scene contains these
|
31 |
* values:
|
32 |
* \li an upper-left (x,y) position
|
33 |
* \li a width and a height
|
34 |
* \li a magnification
|
35 |
*
|
36 |
* The (X,Y) point is expressed in pixel-space (mag=1.0) coordinates, relative
|
37 |
* to the given magnification. The width and height are absolutes, i.e. they
|
38 |
* correspond to the buffer size the user expects.
|
39 |
*
|
40 |
* The scene position and dimensions are maintained as high-precision values.
|
41 |
* Accessors are supplied to get the high-precision values as well as the
|
42 |
* properly rounded integral values (expressed in row/col form).
|
43 |
*
|
44 |
* A mag value of 1.0 indicates full-size resolution. A mag greater than 1.0
|
45 |
* indicates res-up (zoom in) by a factor of two: 2.0 gives an image 2x bigger,
|
46 |
* 4.0 gives an image 4x bigger, etc. A mag value less than 1.0 indicates
|
47 |
* a lower resolution: 0.5 gives a half-sized image, 0.25 gives a quarter-sized
|
48 |
* image, etc.
|
49 |
*
|
50 |
* An LTIImageReader may not support the requested magnification: most readers
|
51 |
* only support mag=1.0, and MrSID readers only support power-of-two magnifications (0.25,
|
52 |
* 0.5, 1.0, 2.0, 4.0, etc). If the mag request cannot be returned the extraction
|
53 |
* will return an error.
|
54 |
*
|
55 |
* An LTIScene is used to express the region of an image to be decoded via a
|
56 |
* call to LTIImageReader::decodeBegin(), etc.
|
57 |
*
|
58 |
* As an example, consider an image which is 512x512 pixels. Then, the
|
59 |
* following scenes from the image will all contain the same upper-left point
|
60 |
* and all will be 100x100 pixels. The "granularity" (resolution) of each
|
61 |
* pixel, however, will differ.
|
62 |
* \li <tt>const LTIScene scene(256, 256, 100, 100, 1.0); // center point</tt>
|
63 |
* \li <tt>const LTIScene scene(512, 512, 100, 100, 2.0);</tt>
|
64 |
* \li <tt>const LTIScene scene(128, 128, 100, 100, 0.5);</tt>
|
65 |
*
|
66 |
* @note Scenes may not require a buffer larger than 2GB.
|
67 |
*/
|
68 |
class LTIScene |
69 |
{ |
70 |
public:
|
71 |
/**
|
72 |
* constructor
|
73 |
*
|
74 |
* This constructor produces a scene set to the given parameters, using double-precision.
|
75 |
*
|
76 |
* @param ulX upper left X position of scene
|
77 |
* @param ulY upper left Y position of scene
|
78 |
* @param width width of scene
|
79 |
* @param height height of scene
|
80 |
* @param magnification resolution of scene
|
81 |
*/
|
82 |
LTIScene(double ulX, double ulY, |
83 |
double width, double height, |
84 |
double magnification);
|
85 |
|
86 |
/**
|
87 |
* copy constructor
|
88 |
*/
|
89 |
LTIScene(const LTIScene& copy);
|
90 |
|
91 |
/**
|
92 |
* default constructor
|
93 |
*
|
94 |
* This constructor will produce a scene with "invalid" default
|
95 |
* coordinates.
|
96 |
*/
|
97 |
LTIScene(void);
|
98 |
|
99 |
/**
|
100 |
* assignment operator
|
101 |
*/
|
102 |
LTIScene& operator=(const LTIScene&);
|
103 |
|
104 |
/**
|
105 |
* equality operator
|
106 |
*/
|
107 |
bool operator==(const LTIScene&) const; |
108 |
|
109 |
/**
|
110 |
* equality operator
|
111 |
*/
|
112 |
bool operator!=(const LTIScene&) const; |
113 |
|
114 |
|
115 |
/**
|
116 |
* returns the magnification of the scene
|
117 |
*
|
118 |
* Returns the magnification of the scene.
|
119 |
*
|
120 |
* @return the magnification
|
121 |
*/
|
122 |
double getMag() const; |
123 |
|
124 |
|
125 |
/**
|
126 |
* @name High-precision point functions
|
127 |
*/
|
128 |
/*@{*/
|
129 |
|
130 |
/**
|
131 |
* returns the x-position of the upper-left point
|
132 |
*
|
133 |
* Returns the x-position of the upper-left point. This is a high-precision value.
|
134 |
*
|
135 |
* @return the x-position of the point
|
136 |
*/
|
137 |
double getUpperLeftX() const; |
138 |
|
139 |
/**
|
140 |
* returns the y-position of the upper-left point
|
141 |
*
|
142 |
* Returns the y-position of the upper-left point. This is a high-precision value.
|
143 |
*
|
144 |
* @return the y-position of the point
|
145 |
*/
|
146 |
double getUpperLeftY() const; |
147 |
|
148 |
/**
|
149 |
* returns the x-position of the lower-right point
|
150 |
*
|
151 |
* Returns the x-position of the lower-right point. This is a high-precision value.
|
152 |
*
|
153 |
* @return the x-position of the point
|
154 |
*/
|
155 |
double getLowerRightX() const; |
156 |
|
157 |
/**
|
158 |
* returns the y-position of the lower-right point
|
159 |
*
|
160 |
* Returns the y-position of the lower-right point. This is a high-precision value.
|
161 |
*
|
162 |
* @return the y-position of the point
|
163 |
*/
|
164 |
double getLowerRightY() const; |
165 |
|
166 |
/**
|
167 |
* returns the x-position of the upper-right point
|
168 |
*
|
169 |
* Returns the x-position of the upper-right point. This is a high-precision value.
|
170 |
*
|
171 |
* @return the x-position of the point
|
172 |
*/
|
173 |
double getUpperRightX() const; |
174 |
|
175 |
/**
|
176 |
* returns the y-position of the upper-left point
|
177 |
*
|
178 |
* Returns the y-position of the upper-left point. This is a high-precision value.
|
179 |
*
|
180 |
* @return the y-position of the point
|
181 |
*/
|
182 |
double getUpperRightY() const; |
183 |
|
184 |
/**
|
185 |
* returns the x-position of the lower-left point
|
186 |
*
|
187 |
* Returns the x-position of the lower-left point. This is a high-precision value.
|
188 |
*
|
189 |
* @return the x-position of the point
|
190 |
*/
|
191 |
double getLowerLeftX() const; |
192 |
|
193 |
/**
|
194 |
* returns the y-position of the lower-left point
|
195 |
*
|
196 |
* Returns the y-position of the lower-left point. This is a high-precision value.
|
197 |
*
|
198 |
* @return the y-position of the point
|
199 |
*/
|
200 |
double getLowerLeftY() const; |
201 |
|
202 |
/**
|
203 |
* returns the x-position of the center point
|
204 |
*
|
205 |
* Returns the x-position of the center point. This is a high-precision value.
|
206 |
*
|
207 |
* @return the x-position of the point
|
208 |
*/
|
209 |
double getCenterX() const; |
210 |
|
211 |
/**
|
212 |
* returns the x-position of the center point
|
213 |
*
|
214 |
* Returns the x-position of the center point. This is a high-precision value.
|
215 |
*
|
216 |
* @return the x-position of the point
|
217 |
*/
|
218 |
double getCenterY() const; |
219 |
|
220 |
/*@}*/
|
221 |
|
222 |
|
223 |
/**
|
224 |
* @name Low-precision point functions
|
225 |
*
|
226 |
* These functions return properly rounded integral values, to be used
|
227 |
* only when discretizing the pixels (for example to map to a buffer in
|
228 |
* memory).
|
229 |
*/
|
230 |
/*@{*/
|
231 |
|
232 |
/**
|
233 |
* returns the x-position of the upper-left point
|
234 |
*
|
235 |
* Returns the x-position of the upper-left point. This is a low-precision value.
|
236 |
*
|
237 |
* @return the x-position of the point
|
238 |
*/
|
239 |
lt_int32 getUpperLeftCol() const;
|
240 |
|
241 |
/**
|
242 |
* returns the y-position of the upper-left point
|
243 |
*
|
244 |
* Returns the y-position of the upper-left point. This is a low-precision value.
|
245 |
*
|
246 |
* @return the y-position of the point
|
247 |
*/
|
248 |
lt_int32 getUpperLeftRow() const;
|
249 |
|
250 |
/**
|
251 |
* returns the x-position of the lower-right point
|
252 |
*
|
253 |
* Returns the x-position of the lower-right point. This is a low-precision value.
|
254 |
*
|
255 |
* @return the x-position of the point
|
256 |
*/
|
257 |
lt_int32 getLowerRightCol() const;
|
258 |
|
259 |
/**
|
260 |
* returns the y-position of the lower-right point
|
261 |
*
|
262 |
* Returns the y-position of the lower-right point. This is a low-precision value.
|
263 |
*
|
264 |
* @return the y-position of the point
|
265 |
*/
|
266 |
lt_int32 getLowerRightRow() const;
|
267 |
|
268 |
/**
|
269 |
* returns the x-position of the upper-right point
|
270 |
*
|
271 |
* Returns the x-position of the upper-right point. This is a low-precision value.
|
272 |
*
|
273 |
* @return the x-position of the point
|
274 |
*/
|
275 |
lt_int32 getUpperRightCol() const;
|
276 |
|
277 |
/**
|
278 |
* returns the y-position of the upper-right point
|
279 |
*
|
280 |
* Returns the y-position of the upper-right point. This is a low-precision value.
|
281 |
*
|
282 |
* @return the y-position of the point
|
283 |
*/
|
284 |
lt_int32 getUpperRightRow() const;
|
285 |
|
286 |
/**
|
287 |
* returns the x-position of the lower-left point
|
288 |
*
|
289 |
* Returns the x-position of the lower-left point. This is a low-precision value.
|
290 |
*
|
291 |
* @return the x-position of the point
|
292 |
*/
|
293 |
lt_int32 getLowerLeftCol() const;
|
294 |
|
295 |
/**
|
296 |
* returns the y-position of the lower-left point
|
297 |
*
|
298 |
* Returns the y-position of the lower-left point. This is a low-precision value.
|
299 |
*
|
300 |
* @return the y-position of the point
|
301 |
*/
|
302 |
lt_int32 getLowerLeftRow() const;
|
303 |
|
304 |
/**
|
305 |
* returns the x-position of the center point
|
306 |
*
|
307 |
* Returns the x-position of the center point. This is a low-precision value.
|
308 |
*
|
309 |
* @return the x-position of the point
|
310 |
*/
|
311 |
lt_int32 getCenterCol() const;
|
312 |
|
313 |
/**
|
314 |
* returns the y-position of the center point
|
315 |
*
|
316 |
* Returns the y-position of the center point. This is a low-precision value.
|
317 |
*
|
318 |
* @return the y-position of the point
|
319 |
*/
|
320 |
lt_int32 getCenterRow() const;
|
321 |
|
322 |
/*@}*/
|
323 |
|
324 |
|
325 |
/**
|
326 |
* @name Dimension functions
|
327 |
*
|
328 |
*/
|
329 |
/*@{*/
|
330 |
|
331 |
/**
|
332 |
* returns the width of the scene
|
333 |
*
|
334 |
* Returns the width of the scene. This is a high-precision value.
|
335 |
*
|
336 |
* @return the width
|
337 |
*/
|
338 |
double getWidth() const; |
339 |
|
340 |
/**
|
341 |
* returns the height of the scene
|
342 |
*
|
343 |
* Returns the height of the scene. This is a high-precision value.
|
344 |
*
|
345 |
* @return the height
|
346 |
*/
|
347 |
double getHeight() const; |
348 |
|
349 |
/**
|
350 |
* returns the width of the scene
|
351 |
*
|
352 |
* Returns the width of the scene. This is a low-precision value.
|
353 |
*
|
354 |
* @return the width
|
355 |
*/
|
356 |
lt_int32 getNumCols() const;
|
357 |
|
358 |
/**
|
359 |
* returns the height of the scene
|
360 |
*
|
361 |
* Returns the height of the scene. This is a low-precision value.
|
362 |
*
|
363 |
* @return the height
|
364 |
*/
|
365 |
lt_int32 getNumRows() const;
|
366 |
|
367 |
/*@}*/
|
368 |
|
369 |
|
370 |
/**
|
371 |
* @name Helper functions
|
372 |
*
|
373 |
*/
|
374 |
/*@{*/
|
375 |
|
376 |
/**
|
377 |
* returns the x-position of the upper-left point
|
378 |
*
|
379 |
* Returns the x-position of the upper-left point, as a high-precision
|
380 |
* value. This returns the same value as calling getUpperLeftX().
|
381 |
*
|
382 |
* @return the x-position of the point
|
383 |
*/
|
384 |
double getX() const; |
385 |
|
386 |
/**
|
387 |
* returns the y-position of the upper-left point
|
388 |
*
|
389 |
* Returns the y-position of the upper-left point, as a high-precision
|
390 |
* value. This returns the same value as calling getUpperLeftY().
|
391 |
*
|
392 |
* @return the y-position of the point
|
393 |
*/
|
394 |
double getY() const; |
395 |
|
396 |
/**
|
397 |
* returns the (x,y) positions of the upper-left and lower-right points
|
398 |
*
|
399 |
* Returns the (x,y) positions of the upper-left and lower-right points,
|
400 |
* as high-precision values.
|
401 |
*
|
402 |
* @param ulX the upper-left x-position
|
403 |
* @param ulY the upper-left y-position
|
404 |
* @param lrX the lower-right x-position
|
405 |
* @param lrY the lower-right y-position
|
406 |
*/
|
407 |
void getPoints(double& ulX, double& ulY, |
408 |
double& lrX, double& lrY) const; |
409 |
|
410 |
/**
|
411 |
* returns the (x,y) positions of the center and corner points
|
412 |
*
|
413 |
* Returns the (x,y) positions of the center and corner points,
|
414 |
* as high-precision values.
|
415 |
*
|
416 |
* @param ulX the upper-left x-position
|
417 |
* @param ulY the upper-left y-position
|
418 |
* @param urX the upper-right x-position
|
419 |
* @param urY the upper-right y-position
|
420 |
* @param llX the lower-left x-position
|
421 |
* @param llY the lower-left y-position
|
422 |
* @param lrX the lower-right x-position
|
423 |
* @param lrY the lower-right y-position
|
424 |
* @param cX the center x-position
|
425 |
* @param cY the center y-position
|
426 |
*/
|
427 |
void getPoints(double& ulX, double& ulY, |
428 |
double& urX, double& urY, |
429 |
double& llX, double& llY, |
430 |
double& lrX, double& lrY, |
431 |
double& cX, double& cY) const; |
432 |
|
433 |
/**
|
434 |
* returns the (x,y) positions of the upper-left and lower-right points
|
435 |
*
|
436 |
* Returns the (x,y) positions of the upper-left and lower-right points,
|
437 |
* as low-precision values.
|
438 |
*
|
439 |
* @param ulX the upper-left x-position
|
440 |
* @param ulY the upper-left y-position
|
441 |
* @param lrX the lower-right x-position
|
442 |
* @param lrY the lower-right y-position
|
443 |
*/
|
444 |
void getPoints(lt_int32& ulX, lt_int32& ulY,
|
445 |
lt_int32& lrX, lt_int32& lrY) const;
|
446 |
|
447 |
/**
|
448 |
* returns the (x,y) positions of the center and corner points
|
449 |
*
|
450 |
* Returns the (x,y) positions of the center and corner points,
|
451 |
* as low-precision values.
|
452 |
*
|
453 |
* @param ulX the upper-left x-position
|
454 |
* @param ulY the upper-left y-position
|
455 |
* @param urX the upper-right x-position
|
456 |
* @param urY the upper-right y-position
|
457 |
* @param llX the lower-left x-position
|
458 |
* @param llY the lower-left y-position
|
459 |
* @param lrX the lower-right x-position
|
460 |
* @param lrY the lower-right y-position
|
461 |
* @param cX the center x-position
|
462 |
* @param cY the center y-position
|
463 |
*/
|
464 |
void getPoints(lt_int32& ulX, lt_int32& ulY,
|
465 |
lt_int32& urX, lt_int32& urY, |
466 |
lt_int32& llX, lt_int32& llY, |
467 |
lt_int32& lrX, lt_int32& lrY, |
468 |
lt_int32& cX, lt_int32& cY) const;
|
469 |
/*@}*/
|
470 |
|
471 |
protected:
|
472 |
double m_ulX, m_ulY;
|
473 |
double m_width, m_height;
|
474 |
double m_magnification;
|
475 |
|
476 |
private:
|
477 |
lt_int32 getHalfWidth_i() const;
|
478 |
lt_int32 getHalfHeight_i() const;
|
479 |
}; |
480 |
|
481 |
|
482 |
LT_END_NAMESPACE(LizardTech) |
483 |
|
484 |
#if defined(LT_COMPILER_MS)
|
485 |
#pragma warning(pop)
|
486 |
#endif
|
487 |
|
488 |
#endif // LTI_SCENE_H |