svn-gvsig-desktop / trunk / libraries / libjni-mrsid / include / base / lti_utils.h @ 3539
History | View | Annotate | Download (5.47 KB)
1 |
/* $Id: lti_utils.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_UTILS_H
|
14 |
#define LTI_UTILS_H
|
15 |
|
16 |
// lt_lib_base
|
17 |
#include "lt_base.h" |
18 |
|
19 |
// lt_lib_mrsid_core
|
20 |
#include "lti_types.h" |
21 |
|
22 |
|
23 |
LT_BEGIN_NAMESPACE(LizardTech) |
24 |
|
25 |
#if defined(LT_COMPILER_MS)
|
26 |
#pragma warning(push,4) |
27 |
#endif
|
28 |
|
29 |
/**
|
30 |
* utility functions
|
31 |
*
|
32 |
* The LTIUtils class contains a number of generally useful static functions, e.g.
|
33 |
* functions which operate on the enums declared in lti_types.h
|
34 |
*
|
35 |
* @note This is a "static" class; do not instantiate.
|
36 |
*/
|
37 |
class LTIUtils |
38 |
{ |
39 |
public:
|
40 |
/**
|
41 |
* returns number of samples per pixel
|
42 |
*
|
43 |
* This function returns the number of samples (bands) per pixel
|
44 |
* for the given colorspace, e.g. 3 for RGB. If the number of
|
45 |
* bands is not known for a given colorspace, 0 will be returned.
|
46 |
*
|
47 |
* @param colorspace the colorspace to query
|
48 |
* @return the number of bands
|
49 |
*/
|
50 |
static lt_uint8 getSamplesPerPixel(LTIColorSpace colorspace);
|
51 |
|
52 |
/**
|
53 |
* returns number of bytes for a given a datatype
|
54 |
*
|
55 |
* This function returns the number of bytes for a given datatype,
|
56 |
* e.g. 1 for LTI_DATATYPE_UINT8 or 4 for LTI_DATATYPE_FLOAT32.
|
57 |
*
|
58 |
* @param datatype the datatype to query
|
59 |
* @return the number of bytes
|
60 |
*/
|
61 |
static lt_uint8 getNumBytes(LTIDataType datatype);
|
62 |
|
63 |
/**
|
64 |
* @name Dynamic range conversion functions
|
65 |
*/
|
66 |
/*@{*/
|
67 |
|
68 |
/**
|
69 |
* convert from window/level to min/max
|
70 |
*
|
71 |
* This function converts a "window and level" style of dynamic range
|
72 |
* to a "minimum and maximum" style.
|
73 |
*
|
74 |
* @param window the window value
|
75 |
* @param level the level value
|
76 |
* @param drmin the dynamic range minimum value
|
77 |
* @param drmax the dynamic range maximum value
|
78 |
*/
|
79 |
static void convertWindowLevelToMinMax(double window, double level, |
80 |
double& drmin, double& drmax); |
81 |
|
82 |
/**
|
83 |
* convert from min/max to window/level
|
84 |
*
|
85 |
* This function converts a "minimum and maximum" style of dynamic range
|
86 |
* to a "window and level" style.
|
87 |
*
|
88 |
* The "window" is defined as the width of the range, i.e. maximum - minimum + 1.
|
89 |
* The "level" is defined as the center of the window, i.e. minimum + 1/2 * window.
|
90 |
*
|
91 |
* @param drmin the dynamic range minimum value
|
92 |
* @param drmax the dynamic range maximum value
|
93 |
* @param window the window value
|
94 |
* @param level the level value
|
95 |
*/
|
96 |
static void convertMinMaxToWindowLevel(double drmin, double drmax, |
97 |
double& window, double& level); |
98 |
/*@}*/
|
99 |
|
100 |
/**
|
101 |
* @name Mag/level conversion functions
|
102 |
*/
|
103 |
/*@{*/
|
104 |
|
105 |
/**
|
106 |
* convert mag to level
|
107 |
*
|
108 |
* This function converts a "magnification" value to a "level" value.
|
109 |
*
|
110 |
* Examples:
|
111 |
* \li full resolution: mag of 1.0 equals level of 0
|
112 |
* \li down-sampled: mag of 0.5 equals level of 1
|
113 |
* \li up-sampled: mag of 2.0 equals level of -1
|
114 |
*
|
115 |
* @param mag the magnification value to convert
|
116 |
* @return the magnification expressed as a level
|
117 |
*/
|
118 |
static lt_int32 magToLevel(double mag); |
119 |
|
120 |
/**
|
121 |
* convert level to mag
|
122 |
*
|
123 |
* This function converts a "level" value to a "magnification" value.
|
124 |
*
|
125 |
* See magToLevel() for examples.
|
126 |
*
|
127 |
* @param level the level value to convert
|
128 |
* @return the level expressed as a magnification
|
129 |
*/
|
130 |
static double levelToMag(lt_int32 level); |
131 |
/*@}*/
|
132 |
|
133 |
/**
|
134 |
* get SDK version information
|
135 |
*
|
136 |
* This function returns SDK version and build information. The major,
|
137 |
* minor, and revision numbers correspond to the public SDK version
|
138 |
* number. For this SDK series, \a major will be 4. The revision number
|
139 |
* is used to indicate the intermediate release point, e.g. "Technology
|
140 |
* Preview 8". The build number and branch name are for internal use by
|
141 |
* LizardTech.
|
142 |
*
|
143 |
* @param major the major version number
|
144 |
* @param minor the minor version number
|
145 |
* @param revision the revision number
|
146 |
* @param build the build number
|
147 |
* @param branch the branch name
|
148 |
*/
|
149 |
static void getVersionInfo(lt_uint32& major, |
150 |
lt_uint32& minor, |
151 |
lt_uint32& revision, |
152 |
lt_uint32& build, |
153 |
const char*& branch); |
154 |
|
155 |
/**
|
156 |
* get SDK version information as a string
|
157 |
*
|
158 |
* This function returns SDK version and build information as a formatted
|
159 |
* string. The string will be of the form "SDK Version MAJOR.MINOR.REVISION.BUILD.BRANCH",
|
160 |
* using the values returned from LTIUtils::getVersionInfo().
|
161 |
*
|
162 |
* @return the version string
|
163 |
*/
|
164 |
static const char* getVersionString(); |
165 |
|
166 |
private:
|
167 |
// nope
|
168 |
LTIUtils(); |
169 |
LTIUtils(const LTIUtils&);
|
170 |
}; |
171 |
|
172 |
|
173 |
LT_END_NAMESPACE(LizardTech) |
174 |
|
175 |
|
176 |
#if defined(LT_COMPILER_MS)
|
177 |
#pragma warning(pop)
|
178 |
#endif
|
179 |
|
180 |
#endif // LTI_UTILS_H |