1 module dmagick.c.geometry;
2 
3 import dmagick.c.exception;
4 import dmagick.c.image;
5 import dmagick.c.magickType;
6 
7 alias ptrdiff_t ssize_t;
8 
9 extern(C)
10 {
11 	enum GeometryFlags
12 	{
13 		NoValue = 0x0000,
14 
15 		XValue  = 0x0001,
16 		XiValue = 0x0001,
17 
18 		YValue   = 0x0002,
19 		PsiValue = 0x0002,
20 
21 		WidthValue = 0x0004,
22 		RhoValue   = 0x0004,
23 
24 		HeightValue = 0x0008,
25 		SigmaValue  = 0x0008,
26 		ChiValue    = 0x0010,
27 		XiNegative  = 0x0020,
28 
29 		XNegative   = 0x0020,
30 		PsiNegative = 0x0040,
31 
32 		YNegative      = 0x0040,
33 		ChiNegative    = 0x0080,
34 		PercentValue   = 0x1000,  /* '%'  percentage of something */
35 		AspectValue    = 0x2000,  /* '!'  resize no-aspect - special use flag */
36 		NormalizeValue = 0x2000,  /* '!'  ScaleKernelValue() in morphology.c */
37 		LessValue      = 0x4000,  /* '<'  resize smaller - special use flag */
38 		GreaterValue   = 0x8000,  /* '>'  resize larger - spacial use flag */
39 		MinimumValue   = 0x10000, /* '^'  special handling needed */
40 		CorrelateNormalizeValue = 0x10000, /* '^' see ScaleKernelValue() */
41 		AreaValue      = 0x20000, /* '@'  resize to area - special use flag */
42 		DecimalValue   = 0x40000, /* '.'  floating point numbers found */
43 		SeparatorValue = 0x80000, /* 'x'  separator found  */
44 
45 		AllValues = 0x7fffffff
46 	}
47 
48 	/**
49 	 * Specify positioning of an object (e.g. text, image) within a
50 	 * bounding region (e.g. an image). Gravity provides a convenient way to
51 	 * locate objects irrespective of the size of the bounding region, in
52 	 * other words, you don't need to provide absolute coordinates in order
53 	 * to position an object.
54 	 * A common default for gravity is NorthWestGravity.
55 	 */
56 	enum GravityType
57 	{
58 		UndefinedGravity,      ///
59 		ForgetGravity    = 0,  /// Don't use gravity.
60 		NorthWestGravity = 1,  /// Position object at top-left of region.
61 		NorthGravity     = 2,  /// Position object at top-center of region.
62 		NorthEastGravity = 3,  /// Position object at top-right of region.
63 		WestGravity      = 4,  /// Position object at left-center of region.
64 		CenterGravity    = 5,  /// Position object at center of region.
65 		EastGravity      = 6,  /// Position object at right-center of region.
66 		SouthWestGravity = 7,  /// Position object at left-bottom of region.
67 		SouthGravity     = 8,  /// Position object at bottom-center of region.
68 		SouthEastGravity = 9,  /// Position object at bottom-right of region.
69 		StaticGravity    = 10  ///
70 	}
71 
72 	/**
73 	 * An AffineMatrix object describes a coordinate transformation.
74 	 */
75 	struct AffineMatrix
76 	{
77 		double
78 			sx,  /// The amount of scaling on the x-axis.
79 			rx,  /// The amount of rotation on the x-axis, in radians.
80 			ry,  /// The amount of rotation on the y-axis, in radians.
81 			sy,  /// The amount of scaling on the y-axis.
82 			tx,  /// The amount of translation on the x-axis, in pixels.
83 			ty;  /// The amount of translation on the x-axis, in pixels.
84 	}
85 
86 	struct GeometryInfo
87 	{
88 		double
89 			rho,
90 			sigma,
91 			xi,
92 			psi,
93 			chi;
94 	}
95 
96 	struct OffsetInfo
97 	{
98 		ssize_t
99 			x,
100 			y;
101 	}
102 
103 	struct RectangleInfo
104 	{
105 		size_t
106 			width,
107 			height;
108 
109 		ssize_t
110 			x,
111 			y;
112 	}
113 
114 	char* GetPageGeometry(const(char)*);
115 
116 	MagickBooleanType IsGeometry(const(char)*);
117 	MagickBooleanType IsSceneGeometry(const(char)*, const MagickBooleanType);
118 
119 	MagickStatusType GetGeometry(const(char)*, ssize_t*, ssize_t*, size_t*, size_t*);
120 	MagickStatusType ParseAbsoluteGeometry(const(char)*, RectangleInfo*);
121 	MagickStatusType ParseAffineGeometry(const(char)*, AffineMatrix*, ExceptionInfo*);
122 	MagickStatusType ParseGeometry(const(char)*, GeometryInfo*);
123 	MagickStatusType ParseGravityGeometry(const(Image)*, const(char)*, RectangleInfo*, ExceptionInfo*);
124 	MagickStatusType ParseMetaGeometry(const(char)*, ssize_t*, ssize_t*, size_t*, size_t*);
125 	MagickStatusType ParsePageGeometry(const(Image)*, const(char)*, RectangleInfo*, ExceptionInfo*);
126 	MagickStatusType ParseRegionGeometry(const(Image)*, const(char)*, RectangleInfo*, ExceptionInfo*);
127 
128 	void GravityAdjustGeometry(const size_t, const size_t, const GravityType, RectangleInfo*);
129 	void SetGeometry(const(Image)*, RectangleInfo*);
130 	void SetGeometryInfo(GeometryInfo*);
131 }