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