6 * This file is part of the w32api package.
8 * THIS SOFTWARE IS NOT COPYRIGHTED
10 * This source code is offered for use in the public domain. You may
11 * use, modify or distribute it freely.
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.
19 #ifndef _GDIPLUSMATRIX_H
20 #define _GDIPLUSMATRIX_H
22 class Matrix
: public GdiplusBase
26 friend class GraphicsPath
;
28 friend class LinearGradientBrush
;
29 friend class TextureBrush
;
32 Matrix(const RectF
&rect
, const PointF
*dstplg
)
34 lastStatus
= DllExports::GdipCreateMatrix3(&rect
, dstplg
, &nativeMatrix
);
37 Matrix(const Rect
&rect
, const Point
*dstplg
)
39 lastStatus
= DllExports::GdipCreateMatrix3I(&rect
, dstplg
, &nativeMatrix
);
44 lastStatus
= DllExports::GdipCreateMatrix(&nativeMatrix
);
47 Matrix(REAL m11
, REAL m12
, REAL m21
, REAL m22
, REAL dx
, REAL dy
)
49 lastStatus
= DllExports::GdipCreateMatrix2(m11
, m12
, m21
, m22
, dx
, dy
, &nativeMatrix
);
55 GpMatrix
*cloneMatrix
= NULL
;
56 SetStatus(DllExports::GdipCloneMatrix(nativeMatrix
, &cloneMatrix
));
61 Matrix
*newMatrix
= new Matrix(cloneMatrix
);
63 DllExports::GdipDeleteMatrix(cloneMatrix
);
70 DllExports::GdipDeleteMatrix(nativeMatrix
);
74 Equals(const Matrix
*matrix
) const
77 SetStatus(DllExports::GdipIsMatrixEqual(nativeMatrix
, matrix
? getNat(matrix
) : NULL
, &result
));
82 GetElements(REAL
*m
) const
84 return SetStatus(DllExports::GdipGetMatrixElements(nativeMatrix
, m
));
96 return SetStatus(DllExports::GdipInvertMatrix(nativeMatrix
));
103 SetStatus(DllExports::GdipIsMatrixIdentity(nativeMatrix
, &result
));
111 SetStatus(DllExports::GdipIsMatrixInvertible(nativeMatrix
, &result
));
116 Multiply(const Matrix
*matrix
, MatrixOrder order
= MatrixOrderPrepend
)
118 return SetStatus(DllExports::GdipMultiplyMatrix(nativeMatrix
, matrix
? getNat(matrix
) : NULL
, order
));
125 if (GetElements(elements
) == Ok
)
134 if (GetElements(elements
) == Ok
)
142 return SetStatus(DllExports::GdipSetMatrixElements(nativeMatrix
, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0));
146 Rotate(REAL angle
, MatrixOrder order
= MatrixOrderPrepend
)
148 return SetStatus(DllExports::GdipRotateMatrix(nativeMatrix
, angle
, order
));
152 RotateAt(REAL angle
, const PointF
¢er
, MatrixOrder order
= MatrixOrderPrepend
)
154 if (order
== MatrixOrderPrepend
)
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
));
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
));
169 Scale(REAL scaleX
, REAL scaleY
, MatrixOrder order
= MatrixOrderPrepend
)
171 return SetStatus(DllExports::GdipScaleMatrix(nativeMatrix
, scaleX
, scaleY
, order
));
175 SetElements(REAL m11
, REAL m12
, REAL m21
, REAL m22
, REAL dx
, REAL dy
)
177 return SetStatus(DllExports::GdipSetMatrixElements(nativeMatrix
, m11
, m12
, m21
, m22
, dx
, dy
));
181 Shear(REAL shearX
, REAL shearY
, MatrixOrder order
= MatrixOrderPrepend
)
183 return SetStatus(DllExports::GdipShearMatrix(nativeMatrix
, shearX
, shearY
, order
));
187 TransformPoints(Point
*pts
, INT count
)
189 return SetStatus(DllExports::GdipTransformMatrixPointsI(nativeMatrix
, pts
, count
));
193 TransformPoints(PointF
*pts
, INT count
)
195 return SetStatus(DllExports::GdipTransformMatrixPoints(nativeMatrix
, pts
, count
));
199 TransformVectors(Point
*pts
, INT count
)
201 return SetStatus(DllExports::GdipVectorTransformMatrixPointsI(nativeMatrix
, pts
, count
));
205 TransformVectors(PointF
*pts
, INT count
)
207 return SetStatus(DllExports::GdipVectorTransformMatrixPoints(nativeMatrix
, pts
, count
));
211 Translate(REAL offsetX
, REAL offsetY
, MatrixOrder order
= MatrixOrderPrepend
)
213 return SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix
, offsetX
, offsetY
, order
));
217 GpMatrix
*nativeMatrix
;
218 mutable Status lastStatus
;
220 Matrix(GpMatrix
*matrix
) : nativeMatrix(matrix
), lastStatus(Ok
)
225 SetStatus(Status status
) const
233 friend inline GpMatrix
*&
234 getNat(const Matrix
*matrix
)
236 return const_cast<Matrix
*>(matrix
)->nativeMatrix
;
240 #endif /* _GDIPLUSMATRIX_H */