1 module dmagick.c.magickType; 2 3 import dmagick.c.magickVersion; 4 5 extern (C) 6 { 7 version(X86) 8 { 9 alias real MagickFloatT; 10 alias real MagickDoubleT; 11 } 12 else version(X86_64) 13 { 14 alias float MagickFloatT; 15 alias double MagickDoubleT; 16 } 17 18 version(Quantum8) 19 { 20 /** 21 * Quantum is an alias for the smallest integer that can hold 22 * a pixel channel. 23 */ 24 version(MagickCore_HDRI) 25 alias float Quantum; 26 else 27 alias ubyte Quantum; 28 29 alias ptrdiff_t SignedQuantum; 30 31 static if ( MagickLibVersion == 0x680 ) 32 alias float MagickRealType; 33 else static if ( MagickLibVersion >= 0x681 ) 34 alias MagickFloatT MagickRealType; 35 else 36 alias double MagickRealType; 37 38 /** 39 * The largest value that fits in a Quantum, This is the same 40 * as Quantum.max except when the Quantum dept is 64 bits. 41 */ 42 enum QuantumRange = ubyte.max; 43 enum MagickQuantumDepth = 8; 44 enum MaxColormapSize = 256; 45 46 static if ( MagickLibVersion < 0x678 ) 47 { 48 enum MagickEpsilon = 1.0e-6; 49 enum MagickHuge = 1.0e6; 50 } 51 } 52 else version(Quantum32) 53 { 54 /** 55 * Quantum is an alias for the smallest integer that can hold 56 * a pixel channel. 57 */ 58 version(MagickCore_HDRI) 59 { 60 static if ( MagickLibVersion >= 0x690 ) 61 alias double Quantum; 62 else 63 alias float Quantum; 64 } 65 else 66 { 67 alias uint Quantum; 68 } 69 70 alias double SignedQuantum; 71 72 static if ( MagickLibVersion >= 0x681 ) 73 alias MagickDoubleT MagickRealType; 74 else 75 alias double MagickRealType; 76 77 /** 78 * The largest value that fits in a Quantum, This is the same 79 * as Quantum.max except when the Quantum dept is 64 bits. 80 */ 81 enum QuantumRange = uint.max; 82 enum MagickQuantumDepth = 32; 83 enum MaxColormapSize = 65536; 84 85 static if ( MagickLibVersion < 0x678 ) 86 { 87 enum MagickEpsilon = 1.0e-10; 88 enum MagickHuge = 1.0e12; 89 } 90 } 91 else version(Quantum64) 92 { 93 /** 94 * Quantum is an alias for the smallest integer that can hold 95 * a pixel channel. 96 */ 97 static if ( MagickLibVersion >= 0x690 ) 98 { 99 alias real Quantum; 100 alias real SignedQuantum; 101 } 102 else 103 { 104 alias double Quantum; 105 alias double SignedQuantum; 106 } 107 //real seems to be the same size as long double for 108 //dmc and dmd on windows and for dmd and gcc on linux. 109 alias real MagickRealType; 110 111 /** 112 * The largest value that fits in a Quantum, This is the same 113 * as Quantum.max except when the Quantum dept is 64 bits. 114 */ 115 enum QuantumRange = 18446744073709551615.0; 116 enum MagickQuantumDepth = 64; 117 enum MaxColormapSize = 65536; 118 119 static if ( MagickLibVersion < 0x678 ) 120 { 121 enum MagickEpsilon = 1.0e-10; 122 enum MagickHuge = 1.0e12; 123 } 124 } 125 else 126 { 127 /** 128 * Quantum is an alias for the smallest integer that can hold 129 * a pixel channel. 130 */ 131 version(MagickCore_HDRI) 132 alias float Quantum; 133 else 134 alias ushort Quantum; 135 136 alias ptrdiff_t SignedQuantum; 137 138 static if ( MagickLibVersion == 0x680 ) 139 alias float MagickRealType; 140 else static if ( MagickLibVersion >= 0x681 ) 141 alias MagickFloatT MagickRealType; 142 else 143 alias double MagickRealType; 144 145 /** 146 * The largest value that fits in a Quantum, This is the same 147 * as Quantum.max except when the Quantum dept is 64 bits. 148 */ 149 enum QuantumRange = ushort.max; 150 enum MagickQuantumDepth = 16; 151 enum MaxColormapSize = 65536; 152 153 static if ( MagickLibVersion < 0x678 ) 154 { 155 enum MagickEpsilon = 1.0e-10; 156 enum MagickHuge = 1.0e12; 157 } 158 } 159 160 static if ( MagickLibVersion == 0x678 ) 161 { 162 enum MagickRealType MagickEpsilon = 2.220446e-16; 163 enum MagickRealType MagickHuge = 1.0/MagickEpsilon; 164 } 165 else static if ( MagickLibVersion == 0x679 ) 166 { 167 enum MagickRealType MagickEpsilon = 1.0e-16; 168 enum MagickRealType MagickHuge = 1.0/MagickEpsilon; 169 } 170 else static if ( MagickLibVersion == 0x680 ) 171 { 172 enum MagickRealType MagickEpsilon = 1.0e-16; 173 enum MagickRealType MagickHuge = 3.4e+38; 174 } 175 else static if ( MagickLibVersion >= 0x681 && MagickLibVersion < 0x689 ) 176 { 177 enum MagickRealType MagickEpsilon = 1.0e-15; 178 enum MagickRealType MagickHuge = 3.4e+38; 179 } 180 else static if ( MagickLibVersion >= 0x689 ) 181 { 182 enum MagickRealType MagickEpsilon = 1.0e-15; 183 } 184 185 alias uint MagickStatusType; 186 alias long MagickOffsetType; 187 alias ulong MagickSizeType; 188 alias int MagickBooleanType; 189 190 alias MagickSizeType QuantumAny; 191 alias MaxColormapSize MaxMap; 192 enum MaxTextExtent = 4096; 193 194 enum MagickMaximumValue = 1.79769313486231570E+308; 195 enum MagickMinimumValue = 2.22507385850720140E-308; 196 197 enum QuantumScale = (1.0/ cast(double)QuantumRange); 198 alias QuantumRange TransparentOpacity; /// Fully transparent Quantum. 199 enum OpaqueOpacity = 0; /// Fully opaque Quantum. 200 201 version(D_Ddoc) 202 { 203 /** 204 * Specify an image channel. A channel is a color component of a 205 * pixel. In the RGB colorspace the channels are red, green, and 206 * blue. There may also be an alpha (transparency/opacity) channel. 207 * In the CMYK colorspace the channels area cyan, magenta, yellow, 208 * and black. In the HSL colorspace the channels are hue, saturation, 209 * and lightness. In the Gray colorspace the only channel is gray. 210 */ 211 enum ChannelType 212 { 213 UndefinedChannel, 214 RedChannel = 0x0001, /// 215 GrayChannel = 0x0001, /// 216 CyanChannel = 0x0001, /// 217 GreenChannel = 0x0002, /// 218 MagentaChannel = 0x0002, /// 219 BlueChannel = 0x0004, /// 220 YellowChannel = 0x0004, /// 221 AlphaChannel = 0x0008, /// Same as OpacityChannel 222 OpacityChannel = 0x0008, /// 223 MatteChannel = 0x0008, /// deprecated 224 BlackChannel = 0x0020, /// 225 IndexChannel = 0x0020, /// 226 CompositeChannels = 0x002F, /// 227 AllChannels = 0x7ffffff, /// 228 229 TrueAlphaChannel = 0x0040, /// extract actual alpha channel from opacity 230 RGBChannels = 0x0080, /// set alpha from grayscale mask in RGB 231 GrayChannels = 0x0080, /// 232 SyncChannels = 0x0100, /// channels should be modified equally 233 234 /** 235 * Same as AllChannels, excluding OpacityChannel 236 */ 237 DefaultChannels = ((AllChannels | SyncChannels) &~ OpacityChannel) 238 } 239 } 240 else 241 { 242 mixin( 243 { 244 string channels = "enum ChannelType 245 { 246 UndefinedChannel, 247 RedChannel = 0x0001, 248 GrayChannel = 0x0001, 249 CyanChannel = 0x0001, 250 GreenChannel = 0x0002, 251 MagentaChannel = 0x0002, 252 BlueChannel = 0x0004, 253 YellowChannel = 0x0004, 254 AlphaChannel = 0x0008, 255 OpacityChannel = 0x0008, 256 MatteChannel = 0x0008, // deprecated 257 BlackChannel = 0x0020, 258 IndexChannel = 0x0020, 259 CompositeChannels = 0x002F,"; 260 261 static if ( MagickLibVersion < 0x670 ) 262 { 263 channels ~= "AllChannels = 0x002F,"; 264 } 265 else static if ( MagickLibVersion == 0x670 ) 266 { 267 channels ~= "AllChannels = ~0UL,"; 268 } 269 else static if ( MagickLibVersion == 0x671 ) 270 { 271 channels ~= "AllChannels = ~0L,"; 272 } 273 else 274 { 275 channels ~= "AllChannels = 0x7FFFFFF,"; 276 } 277 278 channels ~= " 279 TrueAlphaChannel = 0x0040, // extract actual alpha channel from opacity 280 RGBChannels = 0x0080, // set alpha from grayscale mask in RGB 281 GrayChannels = 0x0080, 282 SyncChannels = 0x0100, // channels should be modified equally 283 DefaultChannels = ( (AllChannels | SyncChannels) &~ OpacityChannel) 284 }"; 285 286 return channels; 287 }()); 288 } 289 290 /** 291 * Specify the image storage class. 292 */ 293 enum ClassType 294 { 295 UndefinedClass, /// No storage class has been specified. 296 DirectClass, /// Image is composed of pixels which represent literal color values. 297 PseudoClass /// Image is composed of pixels which specify an index in a color palette. 298 } 299 300 struct BlobInfo {} 301 }