summaryrefslogtreecommitdiff
path: root/dmagick/c/magickType.d
blob: 32b2e5fc1e777adfc612dd97adacade569914e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
module dmagick.c.magickType;

import dmagick.c.magickVersion;

extern (C)
{
	version(Quantum8)
	{
		/**
		 * Quantum is an alias for the smallest integer that can hold
		 * a pixel channel.
		 */
		alias ubyte  Quantum;
		alias double MagickRealType;

		/**
		 * The largest value that fits in a Quantum, This is the same
		 * as Quantum.max except when the Quantum dept is 64 bits.
		 */
		enum QuantumRange = Quantum.max;
		enum MAGICKCORE_QUANTUM_DEPTH = 8;
		enum MaxColormapSize = 256;
		enum MagickEpsilon = 1.0e-6;
		enum MagickHuge    = 1.0e6;
	}
	else version(Quantum32)
	{
		/**
		 * Quantum is an alias for the smallest integer that can hold
		 * a pixel channel.
		 */
		alias uint   Quantum;
		alias double MagickRealType;

		/**
		 * The largest value that fits in a Quantum, This is the same
		 * as Quantum.max except when the Quantum dept is 64 bits.
		 */
		enum QuantumRange = Quantum.max;
		enum MAGICKCORE_QUANTUM_DEPTH = 32;
		enum MaxColormapSize = 65536;
		enum MagickEpsilon = 1.0e-10;
		enum MagickHuge    = 1.0e12;
	}
	else version(Quantum64)
	{
		/**
		 * Quantum is an alias for the smallest integer that can hold
		 * a pixel channel.
		 */
		alias double Quantum;
		//real seems to be the same size as long double for
		//dmc and dmd on windows and for dmd and gcc on linux. 
		alias real MagickRealType;

		/**
		 * The largest value that fits in a Quantum, This is the same
		 * as Quantum.max except when the Quantum dept is 64 bits.
		 */
		enum QuantumRange = 18446744073709551615.0;
		enum MAGICKCORE_QUANTUM_DEPTH = 64;
		enum MaxColormapSize = 65536;
		enum MagickEpsilon = 1.0e-10;
		enum MagickHuge = 1.0e12;
	}
	else
	{
		/**
		 * Quantum is an alias for the smallest integer that can hold
		 * a pixel channel.
		 */
		alias ushort Quantum;
		alias double MagickRealType;

		/**
		 * The largest value that fits in a Quantum, This is the same
		 * as Quantum.max except when the Quantum dept is 64 bits.
		 */
		enum QuantumRange = Quantum.max;
		enum MAGICKCORE_QUANTUM_DEPTH = 16;
		enum MaxColormapSize = 65536;
		enum MagickEpsilon = 1.0e-10;
		enum MagickHuge    = 1.0e12;
	}

	alias uint  MagickStatusType;
	alias long  MagickOffsetType;
	alias ulong MagickSizeType;
	alias int   MagickBooleanType;

	alias MagickSizeType  QuantumAny;
	alias MaxColormapSize MaxMap;
	enum  MaxTextExtent = 4096;

	/// The Quantum depth ImageMagick / DMagick is compiled with.
	alias MAGICKCORE_QUANTUM_DEPTH MagickQuantumDepth;

	alias QuantumRange    TransparentOpacity; /// Fully transparent Quantum.
	enum  OpaqueOpacity = 0;                  /// Fully opaque Quantum.

	version(D_Ddoc)
	{
		/**
		 * Specify an image channel. A channel is a color component of a
		 * pixel. In the RGB colorspace the channels are red, green, and
		 * blue. There may also be an alpha (transparency/opacity) channel.
		 * In the CMYK colorspace the channels area cyan, magenta, yellow,
		 * and black. In the HSL colorspace the channels are hue, saturation,
		 * and lightness. In the Gray colorspace the only channel is gray.
		 */
		enum ChannelType
		{
			UndefinedChannel,
			RedChannel     = 0x0001,    ///
			GrayChannel    = 0x0001,    ///
			CyanChannel    = 0x0001,    ///
			GreenChannel   = 0x0002,    ///
			MagentaChannel = 0x0002,    ///
			BlueChannel    = 0x0004,    ///
			YellowChannel  = 0x0004,    ///
			AlphaChannel   = 0x0008,    /// Same as OpacityChannel
			OpacityChannel = 0x0008,    ///
			MatteChannel   = 0x0008,    /// deprecated
			BlackChannel   = 0x0020,    ///
			IndexChannel   = 0x0020,    ///
			CompositeChannels = 0x002F, ///
			AllChannels    = 0x7ffffff, ///

			TrueAlphaChannel = 0x0040, /// extract actual alpha channel from opacity
			RGBChannels      = 0x0080, /// set alpha from  grayscale mask in RGB
			GrayChannels     = 0x0080, ///
			SyncChannels     = 0x0100, /// channels should be modified equally

			/**
			 * Same as AllChannels, excluding OpacityChannel
			 */
			DefaultChannels  = ((AllChannels | SyncChannels) &~ OpacityChannel)
		}
	}
	else
	{
		mixin(
		{
			string channels = "enum ChannelType
			{
				UndefinedChannel,
				RedChannel        = 0x0001,
				GrayChannel       = 0x0001,
				CyanChannel       = 0x0001,
				GreenChannel      = 0x0002,
				MagentaChannel    = 0x0002,
				BlueChannel       = 0x0004,
				YellowChannel     = 0x0004,
				AlphaChannel      = 0x0008,
				OpacityChannel    = 0x0008,
				MatteChannel      = 0x0008,  // deprecated
				BlackChannel      = 0x0020,
				IndexChannel      = 0x0020,
				CompositeChannels = 0x002F,";

				static if ( MagickLibVersion < 0x670 )
				{
					channels ~= "AllChannels = 0x002F,";
				}
				else static if ( MagickLibVersion == 0x670 )
				{
					channels ~= "AllChannels       =   ~0UL,";
				}
				else static if ( MagickLibVersion == 0x671 )
				{
					channels ~= "AllChannels       =    ~0L,";
				}
				else
				{
					channels ~= "AllChannels       = 0x7FFFFFF,";
				}

				channels ~= "
				TrueAlphaChannel = 0x0040, // extract actual alpha channel from opacity
				RGBChannels      = 0x0080, // set alpha from  grayscale mask in RGB
				GrayChannels     = 0x0080,
				SyncChannels     = 0x0100, // channels should be modified equally
				DefaultChannels  = ( (AllChannels | SyncChannels) &~ OpacityChannel)
			}";

			return channels;
		}());
	}

	/**
	 * Specify the image storage class.
	 */
	enum ClassType
	{
		UndefinedClass, /// No storage class has been specified.
		DirectClass,    /// Image is composed of pixels which represent literal color values.
		PseudoClass     /// Image is composed of pixels which specify an index in a color palette.
	}

	struct BlobInfo {}
}