Home | History | Annotate | Download | only in MagickCore
      1 /*
      2   Copyright 1999-2019 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.  You may
      6   obtain a copy of the License at
      7 
      8     https://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 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 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-12)
    111 #define MagickMaximumValue  1.79769313486231570E+308
    112 #define MagickMinimumValue   2.22507385850720140E-308
    113 #define MagickStringify(macro_or_string)  MagickStringifyArg(macro_or_string)
    114 #define MagickStringifyArg(contents)  #contents
    115 #define QuantumScale  ((double) 1.0/(double) QuantumRange)
    116 
    117 /*
    118   Typedef declarations.
    119 */
    120 typedef MagickDoubleType MagickRealType;
    121 typedef unsigned int MagickStatusType;
    122 #if !defined(MAGICKCORE_WINDOWS_SUPPORT)
    123 #if (MAGICKCORE_SIZEOF_UNSIGNED_LONG_LONG == 8)
    124 typedef long long MagickOffsetType;
    125 typedef unsigned long long MagickSizeType;
    126 #define MagickOffsetFormat  "lld"
    127 #define MagickSizeFormat  "llu"
    128 #else
    129 typedef ssize_t MagickOffsetType;
    130 typedef size_t MagickSizeType;
    131 #define MagickOffsetFormat  "ld"
    132 #define MagickSizeFormat  "lu"
    133 #endif
    134 #else
    135 typedef __int64 MagickOffsetType;
    136 typedef unsigned __int64 MagickSizeType;
    137 #define MagickOffsetFormat  "I64i"
    138 #define MagickSizeFormat  "I64u"
    139 #endif
    140 
    141 #if defined(_MSC_VER) && (_MSC_VER == 1200)
    142 typedef MagickOffsetType QuantumAny;
    143 #else
    144 typedef MagickSizeType QuantumAny;
    145 #endif
    146 
    147 #if defined(macintosh)
    148 #define ExceptionInfo  MagickExceptionInfo
    149 #endif
    150 
    151 typedef enum
    152 {
    153   UndefinedClass,
    154   DirectClass,
    155   PseudoClass
    156 } ClassType;
    157 
    158 typedef enum
    159 {
    160   MagickFalse = 0,
    161   MagickTrue = 1
    162 } MagickBooleanType;
    163 
    164 /*
    165   The IsNaN test is for special floating point numbers of value Nan (not a
    166   number). NaN's are defined as part of the IEEE standard for floating point
    167   number representation, and need to be watched out for. Morphology Kernels
    168   often use these special numbers as neighbourhood masks.
    169 
    170   The special property that two NaN's are never equal, even if they are from
    171   the same variable allows you to test if a value is special NaN value.
    172 
    173   The macros are thus is only true if the value given is NaN.
    174 */
    175 #if defined(MAGICKCORE_HAVE_ISNAN)
    176 #  define IsNaN(a) isnan(a)
    177 #elif defined(_MSC_VER) && (_MSC_VER >= 1310)
    178 #  include <float.h>
    179 #  define IsNaN(a) _isnan(a)
    180 #else
    181 #  define IsNaN(a) ((a) != (a))
    182 #endif
    183 #if !defined(INFINITY)
    184 #  define INFINITY (-logf(0f))
    185 #endif
    186 
    187 typedef struct _BlobInfo BlobInfo;
    188 
    189 typedef struct _ExceptionInfo ExceptionInfo;
    190 
    191 typedef struct _Image Image;
    192 
    193 typedef struct _ImageInfo ImageInfo;
    194 
    195 #if defined(__cplusplus) || defined(c_plusplus)
    196 }
    197 #endif
    198 
    199 #endif
    200