blob: 3e1cb76bbf28899547a53024dada628298ad006a [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristyb56bb242014-11-25 17:12:48 +00002 Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization
cristy3ed852e2009-09-05 21:47:34 +00003 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 http://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
cristy6398ec72013-11-28 02:00:27 +000021#include "MagickCore/magick-config.h"
22
cristy3ed852e2009-09-05 21:47:34 +000023#if defined(__cplusplus) || defined(c_plusplus)
24extern "C" {
25#endif
26
cristy3ed852e2009-09-05 21:47:34 +000027#if !defined(MAGICKCORE_QUANTUM_DEPTH)
28#define MAGICKCORE_QUANTUM_DEPTH 16
29#endif
30
cristy277f3a22012-12-10 13:18:45 +000031#if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__) && !defined(__MINGW64__)
cristy3ed852e2009-09-05 21:47:34 +000032# 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
cristyc058afd2012-10-31 11:26:53 +000039#if !defined(MAGICKCORE_HAVE_DOUBLE_T)
40typedef double double_t;
41#endif
42#if !defined(MAGICKCORE_HAVE_FLOAT_T)
43typedef float float_t;
44#endif
45
cristy3ed852e2009-09-05 21:47:34 +000046#if (MAGICKCORE_QUANTUM_DEPTH == 8)
cristy3ed852e2009-09-05 21:47:34 +000047#define MaxColormapSize 256UL
48#define MaxMap 255UL
cristyc058afd2012-10-31 11:26:53 +000049typedef float_t MagickRealType;
cristy3ed852e2009-09-05 21:47:34 +000050
cristy3ed852e2009-09-05 21:47:34 +000051#if defined(MAGICKCORE_HDRI_SUPPORT)
52typedef float Quantum;
53#define QuantumRange 255.0
cristye7f51092010-01-17 00:39:37 +000054#define QuantumFormat "%g"
cristy3ed852e2009-09-05 21:47:34 +000055#else
56typedef unsigned char Quantum;
cristy6e963d82012-06-19 15:23:24 +000057#define QuantumRange ((Quantum) 255)
cristy3ed852e2009-09-05 21:47:34 +000058#define QuantumFormat "%u"
59#endif
60#elif (MAGICKCORE_QUANTUM_DEPTH == 16)
cristy3ed852e2009-09-05 21:47:34 +000061#define MaxColormapSize 65536UL
62#define MaxMap 65535UL
cristyc058afd2012-10-31 11:26:53 +000063typedef float_t MagickRealType;
cristy3ed852e2009-09-05 21:47:34 +000064
cristy3ed852e2009-09-05 21:47:34 +000065#if defined(MAGICKCORE_HDRI_SUPPORT)
66typedef float Quantum;
dirk7493d8f2014-08-10 20:25:32 +000067#define QuantumRange 65535.0f
cristye7f51092010-01-17 00:39:37 +000068#define QuantumFormat "%g"
cristy3ed852e2009-09-05 21:47:34 +000069#else
70typedef unsigned short Quantum;
cristy6e963d82012-06-19 15:23:24 +000071#define QuantumRange ((Quantum) 65535)
cristy3ed852e2009-09-05 21:47:34 +000072#define QuantumFormat "%u"
73#endif
74#elif (MAGICKCORE_QUANTUM_DEPTH == 32)
cristy3ed852e2009-09-05 21:47:34 +000075#define MaxColormapSize 65536UL
76#define MaxMap 65535UL
cristyf314dbd2012-11-15 13:35:28 +000077typedef float_t MagickRealType;
cristy3ed852e2009-09-05 21:47:34 +000078
cristy3ed852e2009-09-05 21:47:34 +000079#if defined(MAGICKCORE_HDRI_SUPPORT)
cristy067638f2014-08-08 14:35:02 +000080typedef double Quantum;
cristy3ed852e2009-09-05 21:47:34 +000081#define QuantumRange 4294967295.0
cristye7f51092010-01-17 00:39:37 +000082#define QuantumFormat "%g"
cristy3ed852e2009-09-05 21:47:34 +000083#else
84typedef unsigned int Quantum;
cristy6e963d82012-06-19 15:23:24 +000085#define QuantumRange ((Quantum) 4294967295)
cristy3ed852e2009-09-05 21:47:34 +000086#define QuantumFormat "%u"
87#endif
cristyf314dbd2012-11-15 13:35:28 +000088#elif (MAGICKCORE_QUANTUM_DEPTH == 64)
cristy8ecccf92012-11-20 15:24:40 +000089#define MAGICKCORE_HDRI_SUPPORT
cristy3ed852e2009-09-05 21:47:34 +000090#define MaxColormapSize 65536UL
91#define MaxMap 65535UL
92
cristy8ecccf92012-11-20 15:24:40 +000093typedef long double MagickRealType;
cristy067638f2014-08-08 14:35:02 +000094typedef long double Quantum;
cristy8ecccf92012-11-20 15:24:40 +000095#define QuantumRange 18446744073709551615.0
cristye7f51092010-01-17 00:39:37 +000096#define QuantumFormat "%g"
cristy3ed852e2009-09-05 21:47:34 +000097#else
cristyfd7a7022012-12-10 13:35:18 +000098#error "MAGICKCORE_QUANTUM_DEPTH must be one of 8, 16, 32, or 64"
cristy3ed852e2009-09-05 21:47:34 +000099#endif
cristy6fb25cc2015-04-06 11:34:31 +0000100#define MagickEpsilon (1.0e-15)
cristyfe181a72014-02-02 21:17:43 +0000101#define MagickMaximumValue 1.79769313486231570E+308
102#define MagickMinimumValue 2.22507385850720140E-308
cristy4c08aed2011-07-01 19:47:50 +0000103#define QuantumScale ((double) 1.0/(double) QuantumRange)
cristy3ed852e2009-09-05 21:47:34 +0000104
105/*
106 Typedef declarations.
107*/
108typedef unsigned int MagickStatusType;
cristy0157aea2010-04-24 21:12:18 +0000109#if !defined(MAGICKCORE_WINDOWS_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000110#if (MAGICKCORE_SIZEOF_UNSIGNED_LONG_LONG == 8)
111typedef long long MagickOffsetType;
112typedef unsigned long long MagickSizeType;
cristy24fb41a2010-06-02 14:01:14 +0000113#define MagickOffsetFormat "lld"
114#define MagickSizeFormat "llu"
cristy3ed852e2009-09-05 21:47:34 +0000115#else
cristybb503372010-05-27 20:51:26 +0000116typedef ssize_t MagickOffsetType;
117typedef size_t MagickSizeType;
cristy24fb41a2010-06-02 14:01:14 +0000118#define MagickOffsetFormat "ld"
119#define MagickSizeFormat "lu"
cristy3ed852e2009-09-05 21:47:34 +0000120#endif
121#else
122typedef __int64 MagickOffsetType;
123typedef unsigned __int64 MagickSizeType;
cristy24fb41a2010-06-02 14:01:14 +0000124#define MagickOffsetFormat "I64i"
125#define MagickSizeFormat "I64u"
cristy3ed852e2009-09-05 21:47:34 +0000126#endif
127
128#if defined(_MSC_VER) && (_MSC_VER == 1200)
129typedef MagickOffsetType QuantumAny;
130#else
131typedef MagickSizeType QuantumAny;
132#endif
133
134#if defined(macintosh)
135#define ExceptionInfo MagickExceptionInfo
136#endif
137
138typedef enum
139{
cristy3ed852e2009-09-05 21:47:34 +0000140 UndefinedClass,
141 DirectClass,
142 PseudoClass
143} ClassType;
144
145typedef enum
146{
147 MagickFalse = 0,
148 MagickTrue = 1
149} MagickBooleanType;
150
anthony6f201312012-03-30 04:08:15 +0000151/*
152 Define some short-hand macros for handling MagickBooleanType
anthony6f201312012-03-30 04:08:15 +0000153 and uses fast C typing with C boolean operations
154
anthonye5b39652012-04-21 05:37:29 +0000155 Is -- returns a MagickBooleanType (for storage)
anthony6f201312012-03-30 04:08:15 +0000156 If -- returns C integer boolean (for if's and while's)
157
anthonye5b39652012-04-21 05:37:29 +0000158 IfMagickTrue() converts MagickBooleanType to C integer Boolean
159 IfMagickFalse() Not the MagickBooleanType to C integer Boolean
anthony6f201312012-03-30 04:08:15 +0000160*/
161#if 1
anthonya322a832013-04-27 06:28:03 +0000162/* Fast C typing method assumes MagickBooleanType match 0,1 values */
anthony7bcfe7f2012-03-30 14:01:22 +0000163# define IfMagickTrue(v) ((int)(v))
164# define IfMagickFalse(v) (!(int)(v))
anthony6f201312012-03-30 04:08:15 +0000165#else
anthonya322a832013-04-27 06:28:03 +0000166/* Do not depend MagickBooleanType's values */
anthony7bcfe7f2012-03-30 14:01:22 +0000167# define IfMagickTrue(v) ((v) != MagickFalse)
168# define IfMagickFalse(v) ((v) == MagickFalse)
anthony6f201312012-03-30 04:08:15 +0000169#endif
anthony6f201312012-03-30 04:08:15 +0000170
anthonya322a832013-04-27 06:28:03 +0000171/*
172 The IsNaN and IfNan tests for special floating point numbers of
173 value NaN (not a number). NaN's are defined as part of the IEEE standard
174 for floating point number representation, and need to be watched out for.
175 Morphology Kernels often use these special numbers as neighbourhood masks.
176
177 The special property that two NaN's are never equal, even if they are from
178 the same variable allows you to test if a value is special NaN value.
179
180 The macros are thus is only true if the value given is NaN.
181*/
182# define IfNaN(a) ((a) != (a))
183# define IsNaN(a) ((a) != (a)?MagickTrue:MagickFalse)
184
185
cristy3ed852e2009-09-05 21:47:34 +0000186typedef struct _BlobInfo BlobInfo;
187
188typedef struct _ExceptionInfo ExceptionInfo;
189
190typedef struct _Image Image;
191
192typedef struct _ImageInfo ImageInfo;
193
194#if defined(__cplusplus) || defined(c_plusplus)
195}
196#endif
197
198#endif