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 		AspectRatioValue = 0x100000, /* '~'  special handling needed  */
45 
46 		AllValues = 0x7fffffff
47 	}
48 
49 	/**
50 	 * Specify positioning of an object (e.g. text, image) within a
51 	 * bounding region (e.g. an image). Gravity provides a convenient way to
52 	 * locate objects irrespective of the size of the bounding region, in
53 	 * other words, you don't need to provide absolute coordinates in order
54 	 * to position an object.
55 	 * A common default for gravity is NorthWestGravity.
56 	 */
57 	enum GravityType
58 	{
59 		UndefinedGravity,      ///
60 		ForgetGravity    = 0,  /// Don't use gravity.
61 		NorthWestGravity = 1,  /// Position object at top-left of region.
62 		NorthGravity     = 2,  /// Position object at top-center of region.
63 		NorthEastGravity = 3,  /// Position object at top-right of region.
64 		WestGravity      = 4,  /// Position object at left-center of region.
65 		CenterGravity    = 5,  /// Position object at center of region.
66 		EastGravity      = 6,  /// Position object at right-center of region.
67 		SouthWestGravity = 7,  /// Position object at left-bottom of region.
68 		SouthGravity     = 8,  /// Position object at bottom-center of region.
69 		SouthEastGravity = 9,  /// Position object at bottom-right of region.
70 		StaticGravity    = 10  ///
71 	}
72 
73 	/**
74 	 * An AffineMatrix object describes a coordinate transformation.
75 	 */
76 	struct AffineMatrix
77 	{
78 		double
79 			sx,  /// The amount of scaling on the x-axis.
80 			rx,  /// The amount of rotation on the x-axis, in radians.
81 			ry,  /// The amount of rotation on the y-axis, in radians.
82 			sy,  /// The amount of scaling on the y-axis.
83 			tx,  /// The amount of translation on the x-axis, in pixels.
84 			ty;  /// The amount of translation on the x-axis, in pixels.
85 	}
86 
87 	struct GeometryInfo
88 	{
89 		double
90 			rho,
91 			sigma,
92 			xi,
93 			psi,
94 			chi;
95 	}
96 
97 	struct OffsetInfo
98 	{
99 		ssize_t
100 			x,
101 			y;
102 	}
103 
104 	struct RectangleInfo
105 	{
106 		size_t
107 			width,
108 			height;
109 
110 		ssize_t
111 			x,
112 			y;
113 	}
114 
115 	char* GetPageGeometry(const(char)*);
116 
117 	MagickBooleanType IsGeometry(const(char)*);
118 	MagickBooleanType IsSceneGeometry(const(char)*, const MagickBooleanType);
119 
120 	MagickStatusType GetGeometry(const(char)*, ssize_t*, ssize_t*, size_t*, size_t*);
121 	MagickStatusType ParseAbsoluteGeometry(const(char)*, RectangleInfo*);
122 	MagickStatusType ParseAffineGeometry(const(char)*, AffineMatrix*, ExceptionInfo*);
123 	MagickStatusType ParseGeometry(const(char)*, GeometryInfo*);
124 	MagickStatusType ParseGravityGeometry(const(Image)*, const(char)*, RectangleInfo*, ExceptionInfo*);
125 	MagickStatusType ParseMetaGeometry(const(char)*, ssize_t*, ssize_t*, size_t*, size_t*);
126 	MagickStatusType ParsePageGeometry(const(Image)*, const(char)*, RectangleInfo*, ExceptionInfo*);
127 	MagickStatusType ParseRegionGeometry(const(Image)*, const(char)*, RectangleInfo*, ExceptionInfo*);
128 
129 	void GravityAdjustGeometry(const size_t, const size_t, const GravityType, RectangleInfo*);
130 	void SetGeometry(const(Image)*, RectangleInfo*);
131 	void SetGeometryInfo(GeometryInfo*);
132 }