ReactOS 0.4.15-dev-8061-g57b775e
gdiplusmatrix.h
Go to the documentation of this file.
1/*
2 * GdiPlusMatrix.h
3 *
4 * Windows GDI+
5 *
6 * This file is part of the w32api package.
7 *
8 * THIS SOFTWARE IS NOT COPYRIGHTED
9 *
10 * This source code is offered for use in the public domain. You may
11 * use, modify or distribute it freely.
12 *
13 * This code is distributed in the hope that it will be useful but
14 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
15 * DISCLAIMED. This includes but is not limited to warranties of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 */
18
19#ifndef _GDIPLUSMATRIX_H
20#define _GDIPLUSMATRIX_H
21
22class Matrix : public GdiplusBase
23{
24 friend class Pen;
25 friend class Region;
26 friend class GraphicsPath;
27 friend class Brush;
28 friend class LinearGradientBrush;
29 friend class TextureBrush;
30
31 public:
32 Matrix(const RectF &rect, const PointF *dstplg)
33 {
34 lastStatus = DllExports::GdipCreateMatrix3(&rect, dstplg, &nativeMatrix);
35 }
36
37 Matrix(const Rect &rect, const Point *dstplg)
38 {
39 lastStatus = DllExports::GdipCreateMatrix3I(&rect, dstplg, &nativeMatrix);
40 }
41
43 {
44 lastStatus = DllExports::GdipCreateMatrix(&nativeMatrix);
45 }
46
48 {
49 lastStatus = DllExports::GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, &nativeMatrix);
50 }
51
52 Matrix *
53 Clone() const
54 {
55 GpMatrix *cloneMatrix = NULL;
56 SetStatus(DllExports::GdipCloneMatrix(nativeMatrix, &cloneMatrix));
57
58 if (lastStatus != Ok)
59 return NULL;
60
61 Matrix *newMatrix = new Matrix(cloneMatrix);
62 if (!newMatrix)
63 DllExports::GdipDeleteMatrix(cloneMatrix);
64
65 return newMatrix;
66 }
67
69 {
70 DllExports::GdipDeleteMatrix(nativeMatrix);
71 }
72
73 BOOL
74 Equals(const Matrix *matrix) const
75 {
77 SetStatus(DllExports::GdipIsMatrixEqual(nativeMatrix, matrix ? getNat(matrix) : NULL, &result));
78 return result;
79 }
80
81 Status
83 {
84 return SetStatus(DllExports::GdipGetMatrixElements(nativeMatrix, m));
85 }
86
87 Status
89 {
90 return lastStatus;
91 }
92
93 Status
95 {
96 return SetStatus(DllExports::GdipInvertMatrix(nativeMatrix));
97 }
98
99 BOOL
101 {
102 BOOL result;
103 SetStatus(DllExports::GdipIsMatrixIdentity(nativeMatrix, &result));
104 return result;
105 }
106
107 BOOL
109 {
110 BOOL result;
111 SetStatus(DllExports::GdipIsMatrixInvertible(nativeMatrix, &result));
112 return result;
113 }
114
115 Status
117 {
118 return SetStatus(DllExports::GdipMultiplyMatrix(nativeMatrix, matrix ? getNat(matrix) : NULL, order));
119 }
120
121 REAL
122 OffsetX() const
123 {
124 REAL elements[6];
125 if (GetElements(elements) == Ok)
126 return elements[4];
127 return 0.0f;
128 }
129
130 REAL
131 OffsetY() const
132 {
133 REAL elements[6];
134 if (GetElements(elements) == Ok)
135 return elements[5];
136 return 0.0f;
137 }
138
139 Status
141 {
142 return SetStatus(DllExports::GdipSetMatrixElements(nativeMatrix, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0));
143 }
144
145 Status
147 {
148 return SetStatus(DllExports::GdipRotateMatrix(nativeMatrix, angle, order));
149 }
150
151 Status
153 {
155 {
156 SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, center.X, center.Y, order));
157 SetStatus(DllExports::GdipRotateMatrix(nativeMatrix, angle, order));
158 return SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, -center.X, -center.Y, order));
159 }
160 else
161 {
162 SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, -center.X, -center.Y, order));
163 SetStatus(DllExports::GdipRotateMatrix(nativeMatrix, angle, order));
164 return SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, center.X, center.Y, order));
165 }
166 }
167
168 Status
170 {
171 return SetStatus(DllExports::GdipScaleMatrix(nativeMatrix, scaleX, scaleY, order));
172 }
173
174 Status
176 {
177 return SetStatus(DllExports::GdipSetMatrixElements(nativeMatrix, m11, m12, m21, m22, dx, dy));
178 }
179
180 Status
182 {
183 return SetStatus(DllExports::GdipShearMatrix(nativeMatrix, shearX, shearY, order));
184 }
185
186 Status
188 {
189 return SetStatus(DllExports::GdipTransformMatrixPointsI(nativeMatrix, pts, count));
190 }
191
192 Status
194 {
195 return SetStatus(DllExports::GdipTransformMatrixPoints(nativeMatrix, pts, count));
196 }
197
198 Status
200 {
201 return SetStatus(DllExports::GdipVectorTransformMatrixPointsI(nativeMatrix, pts, count));
202 }
203
204 Status
206 {
207 return SetStatus(DllExports::GdipVectorTransformMatrixPoints(nativeMatrix, pts, count));
208 }
209
210 Status
212 {
213 return SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, offsetX, offsetY, order));
214 }
215
216 protected:
219
221 {
222 }
223
224 Status
226 {
227 if (status != Ok)
229 return status;
230 }
231
232 // get native
233 friend inline GpMatrix *&
235 {
236 return const_cast<Matrix *>(matrix)->nativeMatrix;
237 }
238};
239
240#endif /* _GDIPLUSMATRIX_H */
Status Reset()
friend GpMatrix *& getNat(const Matrix *matrix)
Matrix(const Rect &rect, const Point *dstplg)
Definition: gdiplusmatrix.h:37
Status GetElements(REAL *m) const
Definition: gdiplusmatrix.h:82
Matrix(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
Definition: gdiplusmatrix.h:47
Status TransformVectors(Point *pts, INT count)
Status Shear(REAL shearX, REAL shearY, MatrixOrder order=MatrixOrderPrepend)
Status TransformVectors(PointF *pts, INT count)
BOOL IsIdentity() const
Status Translate(REAL offsetX, REAL offsetY, MatrixOrder order=MatrixOrderPrepend)
Status TransformPoints(PointF *pts, INT count)
Status Rotate(REAL angle, MatrixOrder order=MatrixOrderPrepend)
Status TransformPoints(Point *pts, INT count)
Status lastStatus
Status Multiply(const Matrix *matrix, MatrixOrder order=MatrixOrderPrepend)
REAL OffsetY() const
Status Scale(REAL scaleX, REAL scaleY, MatrixOrder order=MatrixOrderPrepend)
Matrix * Clone() const
Definition: gdiplusmatrix.h:53
Status SetStatus(Status status) const
Status SetElements(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
GpMatrix * nativeMatrix
Matrix(const RectF &rect, const PointF *dstplg)
Definition: gdiplusmatrix.h:32
Status RotateAt(REAL angle, const PointF &center, MatrixOrder order=MatrixOrderPrepend)
BOOL Equals(const Matrix *matrix) const
Definition: gdiplusmatrix.h:74
Matrix(GpMatrix *matrix)
BOOL IsInvertible() const
Status GetLastStatus() const
Definition: gdiplusmatrix.h:88
Status Invert()
Definition: gdiplusmatrix.h:94
REAL OffsetX() const
Definition: gdipluspen.h:23
#define NULL
Definition: types.h:112
float REAL
Definition: types.h:41
#define m22
#define m11
#define m12
#define m21
unsigned int BOOL
Definition: ntddk_ex.h:94
MatrixOrder
Definition: gdiplusenums.h:187
@ MatrixOrderPrepend
Definition: gdiplusenums.h:188
Status
Definition: gdiplustypes.h:25
@ Ok
Definition: gdiplustypes.h:26
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLenum matrix
Definition: glext.h:9407
GLfloat angle
Definition: glext.h:10853
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
GLuint64EXT * result
Definition: glext.h:11304
const GLfloat * m
Definition: glext.h:10848
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
& rect
Definition: startmenu.cpp:1413
REAL Y
Definition: gdiplustypes.h:649
REAL X
Definition: gdiplustypes.h:648
Definition: ps.c:97
int32_t INT
Definition: typedefs.h:58