]> granicus.if.org Git - imagemagick/blob - MagickCore/magick-type.h
...
[imagemagick] / MagickCore / magick-type.h
1 /*
2   Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization
3   dedicated to making software imaging solutions freely available.
4
5   You may not use this file except in compliance with the License.
6   obtain a copy of the License at
7
8     https://www.imagemagick.org/script/license.php
9  
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15
16   MagickCore types.
17 */
18 #ifndef MAGICKCORE_MAGICK_TYPE_H
19 #define MAGICKCORE_MAGICK_TYPE_H
20
21 #include "MagickCore/magick-config.h"
22
23 #if defined(__cplusplus) || defined(c_plusplus)
24 extern "C" {
25 #endif
26
27 #if !defined(MAGICKCORE_QUANTUM_DEPTH)
28 #define MAGICKCORE_QUANTUM_DEPTH  16
29 #endif
30
31 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__)
32 #  define MagickLLConstant(c)  (MagickOffsetType) (c ## i64)
33 #  define MagickULLConstant(c)  (MagickSizeType) (c ## ui64)
34 #else
35 #  define MagickLLConstant(c)  (MagickOffsetType) (c ## LL)
36 #  define MagickULLConstant(c)  (MagickSizeType) (c ## ULL)
37 #endif
38
39 #if MAGICKCORE_SIZEOF_FLOAT_T == 0
40 typedef float MagickFloatType;
41 #elif (MAGICKCORE_SIZEOF_FLOAT_T == MAGICKCORE_SIZEOF_FLOAT)
42 typedef float MagickFloatType;
43 #elif (MAGICKCORE_SIZEOF_FLOAT_T == MAGICKCORE_SIZEOF_DOUBLE)
44 typedef double MagickFloatType;
45 #elif (MAGICKCORE_SIZEOF_FLOAT_T == MAGICKCORE_SIZEOF_LONG_DOUBLE)
46 typedef long double MagickFloatType;
47 #else
48 #error Your MagickFloatType type is neither a float, nor a double, nor a long double
49 #endif
50 #if MAGICKCORE_SIZEOF_DOUBLE_T == 0
51 typedef double MagickDoubleType;
52 #elif (MAGICKCORE_SIZEOF_DOUBLE_T == MAGICKCORE_SIZEOF_DOUBLE)
53 typedef double MagickDoubleType;
54 #elif (MAGICKCORE_SIZEOF_DOUBLE_T == MAGICKCORE_SIZEOF_LONG_DOUBLE)
55 typedef long double MagickDoubleType;
56 #else
57 #error Your MagickDoubleType type is neither a float, nor a double, nor a long double
58 #endif
59
60 #if (MAGICKCORE_QUANTUM_DEPTH == 8)
61 #define MaxColormapSize  256UL
62 #define MaxMap  255UL
63
64 #if defined(MAGICKCORE_HDRI_SUPPORT)
65 typedef MagickFloatType Quantum;
66 #define QuantumRange  255.0
67 #define QuantumFormat  "%g"
68 #else
69 typedef unsigned char Quantum;
70 #define QuantumRange  ((Quantum) 255)
71 #define QuantumFormat  "%u"
72 #endif
73 #elif (MAGICKCORE_QUANTUM_DEPTH == 16)
74 #define MaxColormapSize  65536UL
75 #define MaxMap  65535UL
76
77 #if defined(MAGICKCORE_HDRI_SUPPORT)
78 typedef MagickFloatType Quantum;
79 #define QuantumRange  65535.0f
80 #define QuantumFormat  "%g"
81 #else
82 typedef unsigned short Quantum;
83 #define QuantumRange  ((Quantum) 65535)
84 #define QuantumFormat  "%u"
85 #endif
86 #elif (MAGICKCORE_QUANTUM_DEPTH == 32)
87 #define MaxColormapSize  65536UL
88 #define MaxMap  65535UL
89
90 #if defined(MAGICKCORE_HDRI_SUPPORT)
91 typedef MagickDoubleType Quantum;
92 #define QuantumRange  4294967295.0
93 #define QuantumFormat  "%g"
94 #else
95 typedef unsigned int Quantum;
96 #define QuantumRange  ((Quantum) 4294967295)
97 #define QuantumFormat  "%u"
98 #endif
99 #elif (MAGICKCORE_QUANTUM_DEPTH == 64)
100 #define MAGICKCORE_HDRI_SUPPORT  1
101 #define MaxColormapSize  65536UL
102 #define MaxMap  65535UL
103
104 typedef MagickDoubleType Quantum;
105 #define QuantumRange  18446744073709551615.0
106 #define QuantumFormat  "%g"
107 #else
108 #error "MAGICKCORE_QUANTUM_DEPTH must be one of 8, 16, 32, or 64"
109 #endif
110 #define MagickEpsilon  (1.0e-15)
111 #define MagickMaximumValue  1.79769313486231570E+308
112 #define MagickMinimumValue   2.22507385850720140E-308
113 #define QuantumScale  ((double) 1.0/(double) QuantumRange)
114
115 /*
116   Typedef declarations.
117 */
118 typedef MagickDoubleType MagickRealType;
119 typedef unsigned int MagickStatusType;
120 #if !defined(MAGICKCORE_WINDOWS_SUPPORT)
121 #if (MAGICKCORE_SIZEOF_UNSIGNED_LONG_LONG == 8)
122 typedef long long MagickOffsetType;
123 typedef unsigned long long MagickSizeType;
124 #define MagickOffsetFormat  "lld"
125 #define MagickSizeFormat  "llu"
126 #else
127 typedef ssize_t MagickOffsetType;
128 typedef size_t MagickSizeType;
129 #define MagickOffsetFormat  "ld"
130 #define MagickSizeFormat  "lu"
131 #endif
132 #else
133 typedef __int64 MagickOffsetType;
134 typedef unsigned __int64 MagickSizeType;
135 #define MagickOffsetFormat  "I64i"
136 #define MagickSizeFormat  "I64u"
137 #endif
138
139 #if defined(_MSC_VER) && (_MSC_VER == 1200)
140 typedef MagickOffsetType QuantumAny;
141 #else
142 typedef MagickSizeType QuantumAny;
143 #endif
144
145 #if defined(macintosh)
146 #define ExceptionInfo  MagickExceptionInfo
147 #endif
148
149 typedef enum
150 {
151   UndefinedClass,
152   DirectClass,
153   PseudoClass
154 } ClassType;
155
156 typedef enum
157 {
158   MagickFalse = 0,
159   MagickTrue = 1
160 } MagickBooleanType;
161
162 /*
163   The IsNaN test is for special floating point numbers of value Nan (not a
164   number). NaN's are defined as part of the IEEE standard for floating point
165   number representation, and need to be watched out for. Morphology Kernels
166   often use these special numbers as neighbourhood masks.
167
168   The special property that two NaN's are never equal, even if they are from
169   the same variable allows you to test if a value is special NaN value.
170
171   The macros are thus is only true if the value given is NaN.
172 */
173 #if defined(MAGICKCORE_HAVE_ISNAN)
174 #  define IsNaN(a) isnan(a)
175 #elif defined(_MSC_VER) && (_MSC_VER >= 1310)
176 #  include <float.h>
177 #  define IsNaN(a) _isnan(a)
178 #else
179 #  define IsNaN(a) (a != a)
180 #endif
181 #if !defined(INFINITY)
182 #  define INFINITY (log(0))
183 #endif
184
185 typedef struct _BlobInfo BlobInfo;
186
187 typedef struct _ExceptionInfo ExceptionInfo;
188
189 typedef struct _Image Image;
190
191 typedef struct _ImageInfo ImageInfo;
192
193 #if defined(__cplusplus) || defined(c_plusplus)
194 }
195 #endif
196
197 #endif