ReactOS 0.4.15-dev-7958-gcd0bb1a
matrix.c File Reference
#include <stdarg.h>
#include <math.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "objbase.h"
#include "gdiplus.h"
#include "gdiplus_private.h"
#include "wine/debug.h"
Include dependency graph for matrix.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (gdiplus)
 
static void matrix_multiply (GDIPCONST REAL *left, GDIPCONST REAL *right, REAL *out)
 
static REAL matrix_det (GDIPCONST GpMatrix *matrix)
 
GpStatus WINGDIPAPI GdipCreateMatrix2 (REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix)
 
GpStatus WINGDIPAPI GdipCreateMatrix3 (GDIPCONST GpRectF *rect, GDIPCONST GpPointF *pt, GpMatrix **matrix)
 
GpStatus WINGDIPAPI GdipCreateMatrix3I (GDIPCONST GpRect *rect, GDIPCONST GpPoint *pt, GpMatrix **matrix)
 
GpStatus WINGDIPAPI GdipCloneMatrix (GpMatrix *matrix, GpMatrix **clone)
 
GpStatus WINGDIPAPI GdipCreateMatrix (GpMatrix **matrix)
 
GpStatus WINGDIPAPI GdipDeleteMatrix (GpMatrix *matrix)
 
GpStatus WINGDIPAPI GdipGetMatrixElements (GDIPCONST GpMatrix *matrix, REAL *out)
 
GpStatus WINGDIPAPI GdipInvertMatrix (GpMatrix *matrix)
 
GpStatus WINGDIPAPI GdipIsMatrixInvertible (GDIPCONST GpMatrix *matrix, BOOL *result)
 
GpStatus WINGDIPAPI GdipMultiplyMatrix (GpMatrix *matrix, GDIPCONST GpMatrix *matrix2, GpMatrixOrder order)
 
GpStatus WINGDIPAPI GdipRotateMatrix (GpMatrix *matrix, REAL angle, GpMatrixOrder order)
 
GpStatus WINGDIPAPI GdipScaleMatrix (GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order)
 
GpStatus WINGDIPAPI GdipSetMatrixElements (GpMatrix *matrix, REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
 
GpStatus WINGDIPAPI GdipShearMatrix (GpMatrix *matrix, REAL shearX, REAL shearY, GpMatrixOrder order)
 
GpStatus WINGDIPAPI GdipTransformMatrixPoints (GpMatrix *matrix, GpPointF *pts, INT count)
 
GpStatus WINGDIPAPI GdipTransformMatrixPointsI (GpMatrix *matrix, GpPoint *pts, INT count)
 
GpStatus WINGDIPAPI GdipTranslateMatrix (GpMatrix *matrix, REAL offsetX, REAL offsetY, GpMatrixOrder order)
 
GpStatus WINGDIPAPI GdipVectorTransformMatrixPoints (GpMatrix *matrix, GpPointF *pts, INT count)
 
GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI (GpMatrix *matrix, GpPoint *pts, INT count)
 
GpStatus WINGDIPAPI GdipIsMatrixEqual (GDIPCONST GpMatrix *matrix, GDIPCONST GpMatrix *matrix2, BOOL *result)
 
GpStatus WINGDIPAPI GdipIsMatrixIdentity (GDIPCONST GpMatrix *matrix, BOOL *result)
 

Function Documentation

◆ GdipCloneMatrix()

GpStatus WINGDIPAPI GdipCloneMatrix ( GpMatrix matrix,
GpMatrix **  clone 
)

Definition at line 125 of file matrix.c.

126{
127 TRACE("(%p, %p)\n", matrix, clone);
128
129 if(!matrix || !clone)
130 return InvalidParameter;
131
132 *clone = heap_alloc_zero(sizeof(GpMatrix));
133 if(!*clone) return OutOfMemory;
134
135 **clone = *matrix;
136
137 return Ok;
138}
@ Ok
Definition: gdiplustypes.h:26
@ InvalidParameter
Definition: gdiplustypes.h:28
@ OutOfMemory
Definition: gdiplustypes.h:29
GLuint GLenum matrix
Definition: glext.h:9407
#define TRACE(s)
Definition: solgame.cpp:4

◆ GdipCreateMatrix()

GpStatus WINGDIPAPI GdipCreateMatrix ( GpMatrix **  matrix)

Definition at line 140 of file matrix.c.

141{
142 TRACE("(%p)\n", matrix);
143
144 if(!matrix)
145 return InvalidParameter;
146
147 *matrix = heap_alloc_zero(sizeof(GpMatrix));
148 if(!*matrix) return OutOfMemory;
149
150 (*matrix)->matrix[0] = 1.0;
151 (*matrix)->matrix[1] = 0.0;
152 (*matrix)->matrix[2] = 0.0;
153 (*matrix)->matrix[3] = 1.0;
154 (*matrix)->matrix[4] = 0.0;
155 (*matrix)->matrix[5] = 0.0;
156
157 return Ok;
158}

Referenced by GdipEnumerateMetafileSrcRectDestPoints(), GdipIsOutlineVisiblePathPoint(), get_pen_transform(), SOFTWARE_GdipDrawPath(), SOFTWARE_GdipDrawThinPath(), test_BeginContainer2(), test_clipping(), test_clipping_2(), test_excludeinfinite(), test_flatten(), test_font_transform(), test_GdipDrawString(), test_Get_Release_DC(), test_getregiondata(), test_gradientgetrect(), test_scans(), test_string_functions(), test_transform(), test_widen(), and test_worldtransform().

◆ GdipCreateMatrix2()

GpStatus WINGDIPAPI GdipCreateMatrix2 ( REAL  m11,
REAL  m12,
REAL  m21,
REAL  m22,
REAL  dx,
REAL  dy,
GpMatrix **  matrix 
)

Definition at line 61 of file matrix.c.

63{
64 TRACE("(%.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %p)\n", m11, m12, m21, m22, dx, dy, matrix);
65
66 if(!matrix)
67 return InvalidParameter;
68
69 *matrix = heap_alloc_zero(sizeof(GpMatrix));
70 if(!*matrix) return OutOfMemory;
71
72 /* first row */
73 (*matrix)->matrix[0] = m11;
74 (*matrix)->matrix[1] = m12;
75 /* second row */
76 (*matrix)->matrix[2] = m21;
77 (*matrix)->matrix[3] = m22;
78 /* third row */
79 (*matrix)->matrix[4] = dx;
80 (*matrix)->matrix[5] = dy;
81
82 return Ok;
83}
#define m22
#define m11
#define m12
#define m21
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97

Referenced by GdipCreateMatrix3(), test_BeginContainer2(), test_constructor_destructor(), test_DrawImage_scale(), test_invert(), test_isidentity(), test_isinfinite(), test_isinvertible(), test_shear(), test_transform(), and test_worldbounds().

◆ GdipCreateMatrix3()

GpStatus WINGDIPAPI GdipCreateMatrix3 ( GDIPCONST GpRectF rect,
GDIPCONST GpPointF pt,
GpMatrix **  matrix 
)

Definition at line 85 of file matrix.c.

87{
88 REAL m11, m12, m21, m22, dx, dy;
89 TRACE("(%p, %p, %p)\n", rect, pt, matrix);
90
91 if(!matrix || !pt)
92 return InvalidParameter;
93
94 m11 = (pt[1].X - pt[0].X) / rect->Width;
95 m21 = (pt[2].X - pt[0].X) / rect->Height;
96 dx = pt[0].X - m11 * rect->X - m21 * rect->Y;
97 m12 = (pt[1].Y - pt[0].Y) / rect->Width;
98 m22 = (pt[2].Y - pt[0].Y) / rect->Height;
99 dy = pt[0].Y - m12 * rect->X - m22 * rect->Y;
100
101 return GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, matrix);
102}
float REAL
Definition: types.h:41
GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix)
Definition: matrix.c:61
#define pt(x, y)
Definition: drawing.c:79
& rect
Definition: startmenu.cpp:1413

Referenced by GdipCreateMatrix3I(), METAFILE_PlaybackUpdateWorldTransform(), and test_constructor3().

◆ GdipCreateMatrix3I()

GpStatus WINGDIPAPI GdipCreateMatrix3I ( GDIPCONST GpRect rect,
GDIPCONST GpPoint pt,
GpMatrix **  matrix 
)

Definition at line 104 of file matrix.c.

106{
107 GpRectF rectF;
108 GpPointF ptF[3];
109 int i;
110
111 TRACE("(%p, %p, %p)\n", rect, pt, matrix);
112
113 rectF.X = (REAL)rect->X;
114 rectF.Y = (REAL)rect->Y;
115 rectF.Width = (REAL)rect->Width;
116 rectF.Height = (REAL)rect->Height;
117
118 for (i = 0; i < 3; i++) {
119 ptF[i].X = (REAL)pt[i].X;
120 ptF[i].Y = (REAL)pt[i].Y;
121 }
122 return GdipCreateMatrix3(&rectF, ptF, matrix);
123}
#define Y(I)
GpStatus WINGDIPAPI GdipCreateMatrix3(GDIPCONST GpRectF *rect, GDIPCONST GpPointF *pt, GpMatrix **matrix)
Definition: matrix.c:85
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REAL Y
Definition: gdiplustypes.h:649
REAL X
Definition: gdiplustypes.h:648
REAL Height
Definition: gdiplustypes.h:664
REAL X
Definition: gdiplustypes.h:661
REAL Width
Definition: gdiplustypes.h:663
REAL Y
Definition: gdiplustypes.h:662

◆ GdipDeleteMatrix()

◆ GdipGetMatrixElements()

GpStatus WINGDIPAPI GdipGetMatrixElements ( GDIPCONST GpMatrix matrix,
REAL out 
)

Definition at line 172 of file matrix.c.

174{
175 TRACE("(%p, %p)\n", matrix, out);
176
177 if(!matrix || !out)
178 return InvalidParameter;
179
180 memcpy(out, matrix->matrix, sizeof(matrix->matrix));
181
182 return Ok;
183}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static FILE * out
Definition: regtests2xml.c:44

Referenced by get_pen_transform(), test_BeginContainer2(), test_constructor3(), test_gradientgetrect(), test_invert(), test_transform(), and test_worldtransform().

◆ GdipInvertMatrix()

GpStatus WINGDIPAPI GdipInvertMatrix ( GpMatrix matrix)

Definition at line 185 of file matrix.c.

186{
188 REAL det;
189 BOOL invertible;
190
191 TRACE("(%p)\n", matrix);
192
193 if(!matrix)
194 return InvalidParameter;
195
196 GdipIsMatrixInvertible(matrix, &invertible);
197 if(!invertible)
198 return InvalidParameter;
199
200 /* optimize inverting simple scaling and translation matrices */
201 if(matrix->matrix[1] == 0 && matrix->matrix[2] == 0)
202 {
203 matrix->matrix[4] = -matrix->matrix[4] / matrix->matrix[0];
204 matrix->matrix[5] = -matrix->matrix[5] / matrix->matrix[3];
205 matrix->matrix[0] = 1 / matrix->matrix[0];
206 matrix->matrix[3] = 1 / matrix->matrix[3];
207
208 return Ok;
209 }
210
211 det = matrix_det(matrix);
212
213 copy = *matrix;
214 /* store result */
215 matrix->matrix[0] = copy.matrix[3] / det;
216 matrix->matrix[1] = -copy.matrix[1] / det;
217 matrix->matrix[2] = -copy.matrix[2] / det;
218 matrix->matrix[3] = copy.matrix[0] / det;
219 matrix->matrix[4] = (copy.matrix[2]*copy.matrix[5]-copy.matrix[3]*copy.matrix[4]) / det;
220 matrix->matrix[5] = -(copy.matrix[0]*copy.matrix[5]-copy.matrix[1]*copy.matrix[4]) / det;
221
222 return Ok;
223}
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
GpStatus WINGDIPAPI GdipIsMatrixInvertible(GDIPCONST GpMatrix *matrix, BOOL *result)
Definition: matrix.c:225
static REAL matrix_det(GDIPCONST GpMatrix *matrix)
Definition: matrix.c:56
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by brush_fill_pixels(), GdipDrawImagePointsRect(), GdipIsOutlineVisiblePathPoint(), get_graphics_transform(), SOFTWARE_GdipDrawPath(), and test_invert().

◆ GdipIsMatrixEqual()

GpStatus WINGDIPAPI GdipIsMatrixEqual ( GDIPCONST GpMatrix matrix,
GDIPCONST GpMatrix matrix2,
BOOL result 
)

Definition at line 499 of file matrix.c.

501{
502 TRACE("(%p, %p, %p)\n", matrix, matrix2, result);
503
504 if(!matrix || !matrix2 || !result)
505 return InvalidParameter;
506 /* based on single array member of GpMatrix */
507 *result = (memcmp(matrix->matrix, matrix2->matrix, sizeof(GpMatrix)) == 0);
508
509 return Ok;
510}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLuint64EXT * result
Definition: glext.h:11304

Referenced by GdipIsMatrixIdentity(), test_invert(), test_shear(), and test_transform().

◆ GdipIsMatrixIdentity()

GpStatus WINGDIPAPI GdipIsMatrixIdentity ( GDIPCONST GpMatrix matrix,
BOOL result 
)

Definition at line 512 of file matrix.c.

513{
514 static const GpMatrix identity =
515 {
516 { 1.0, 0.0,
517 0.0, 1.0,
518 0.0, 0.0 }
519 };
520
521 TRACE("(%p, %p)\n", matrix, result);
522
523 if(!matrix || !result)
524 return InvalidParameter;
525
527}
GpStatus WINGDIPAPI GdipIsMatrixEqual(GDIPCONST GpMatrix *matrix, GDIPCONST GpMatrix *matrix2, BOOL *result)
Definition: matrix.c:499

Referenced by brush_fill_pixels(), GdipSetClipRect(), GdipSetClipRegion(), get_clip_hrgn(), METAFILE_AddPenObject(), test_gradientgetrect(), test_isidentity(), test_transform(), and test_worldtransform().

◆ GdipIsMatrixInvertible()

GpStatus WINGDIPAPI GdipIsMatrixInvertible ( GDIPCONST GpMatrix matrix,
BOOL result 
)

Definition at line 225 of file matrix.c.

226{
227 TRACE("(%p, %p)\n", matrix, result);
228
229 if(!matrix || !result)
230 return InvalidParameter;
231
232 if(matrix->matrix[1] == 0 && matrix->matrix[2] == 0)
233 *result = matrix->matrix[0] != 0 && matrix->matrix[3] != 0;
234 else
235 *result = (fabs(matrix_det(matrix)) >= 1e-5);
236
237 return Ok;
238}
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Definition: fabs.c:17
#define e
Definition: ke_i.h:82

Referenced by GdipInvertMatrix(), and test_isinvertible().

◆ GdipMultiplyMatrix()

GpStatus WINGDIPAPI GdipMultiplyMatrix ( GpMatrix matrix,
GDIPCONST GpMatrix matrix2,
GpMatrixOrder  order 
)

Definition at line 240 of file matrix.c.

242{
243 TRACE("(%p, %p, %d)\n", matrix, matrix2, order);
244
245 if(!matrix || !matrix2)
246 return InvalidParameter;
247
249 matrix_multiply(matrix->matrix, matrix2->matrix, matrix->matrix);
250 else if (order == MatrixOrderPrepend)
251 matrix_multiply(matrix2->matrix, matrix->matrix, matrix->matrix);
252 else
253 return InvalidParameter;
254
255 return Ok;
256}
static void matrix_multiply(GDIPCONST REAL *left, GDIPCONST REAL *right, REAL *out)
Definition: matrix.c:42
@ MatrixOrderAppend
Definition: gdiplusenums.h:189
@ MatrixOrderPrepend
Definition: gdiplusenums.h:188
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194

Referenced by GdipBeginContainer(), GdipMultiplyLineTransform(), GdipMultiplyPathGradientTransform(), GdipMultiplyPenTransform(), GdipMultiplyTextureTransform(), GdipMultiplyWorldTransform(), GdipPlayMetafileRecord(), get_graphics_transform(), linegradient_init_transform(), and METAFILE_PlaybackUpdateWorldTransform().

◆ GdipRotateMatrix()

GpStatus WINGDIPAPI GdipRotateMatrix ( GpMatrix matrix,
REAL  angle,
GpMatrixOrder  order 
)

Definition at line 258 of file matrix.c.

260{
261 REAL cos_theta, sin_theta, rotate[6];
262
263 TRACE("(%p, %.2f, %d)\n", matrix, angle, order);
264
265 if(!matrix)
266 return InvalidParameter;
267
269 cos_theta = cos(angle);
270 sin_theta = sin(angle);
271
272 rotate[0] = cos_theta;
273 rotate[1] = sin_theta;
274 rotate[2] = -sin_theta;
275 rotate[3] = cos_theta;
276 rotate[4] = 0.0;
277 rotate[5] = 0.0;
278
280 matrix_multiply(matrix->matrix, rotate, matrix->matrix);
281 else if (order == MatrixOrderPrepend)
282 matrix_multiply(rotate, matrix->matrix, matrix->matrix);
283 else
284 return InvalidParameter;
285
286 return Ok;
287}
_STLP_MOVE_TO_STD_NAMESPACE void rotate(_ForwardIter __first, _ForwardIter __middle, _ForwardIter __last)
Definition: _algo.c:519
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
static REAL deg2rad(REAL degrees)
GLfloat angle
Definition: glext.h:10853

Referenced by draw_cap(), GdipPlayMetafileRecord(), GdipRotatePathGradientTransform(), GdipRotatePenTransform(), GdipRotateTextureTransform(), GdipRotateWorldTransform(), test_clipping(), test_clipping_2(), test_font_transform(), and test_transform().

◆ GdipScaleMatrix()

GpStatus WINGDIPAPI GdipScaleMatrix ( GpMatrix matrix,
REAL  scaleX,
REAL  scaleY,
GpMatrixOrder  order 
)

Definition at line 289 of file matrix.c.

291{
292 REAL scale[6];
293
294 TRACE("(%p, %.2f, %.2f, %d)\n", matrix, scaleX, scaleY, order);
295
296 if(!matrix)
297 return InvalidParameter;
298
299 scale[0] = scaleX;
300 scale[1] = 0.0;
301 scale[2] = 0.0;
302 scale[3] = scaleY;
303 scale[4] = 0.0;
304 scale[5] = 0.0;
305
307 matrix_multiply(matrix->matrix, scale, matrix->matrix);
308 else if (order == MatrixOrderPrepend)
309 matrix_multiply(scale, matrix->matrix, matrix->matrix);
310 else
311 return InvalidParameter;
312
313 return Ok;
314}
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032

Referenced by draw_cap(), GdipGetLogFontW(), GdipPlayMetafileRecord(), GdipScaleLineTransform(), GdipScalePathGradientTransform(), GdipScalePenTransform(), GdipScaleTextureTransform(), GdipScaleWorldTransform(), get_graphics_transform(), linegradient_init_transform(), METAFILE_PlaybackUpdateWorldTransform(), test_clipping(), test_clipping_2(), test_font_transform(), test_transform(), and test_widen().

◆ GdipSetMatrixElements()

GpStatus WINGDIPAPI GdipSetMatrixElements ( GpMatrix matrix,
REAL  m11,
REAL  m12,
REAL  m21,
REAL  m22,
REAL  dx,
REAL  dy 
)

◆ GdipShearMatrix()

GpStatus WINGDIPAPI GdipShearMatrix ( GpMatrix matrix,
REAL  shearX,
REAL  shearY,
GpMatrixOrder  order 
)

Definition at line 335 of file matrix.c.

337{
338 REAL shear[6];
339
340 TRACE("(%p, %.2f, %.2f, %d)\n", matrix, shearX, shearY, order);
341
342 if(!matrix)
343 return InvalidParameter;
344
345 /* prepare transformation matrix */
346 shear[0] = 1.0;
347 shear[1] = shearY;
348 shear[2] = shearX;
349 shear[3] = 1.0;
350 shear[4] = 0.0;
351 shear[5] = 0.0;
352
354 matrix_multiply(matrix->matrix, shear, matrix->matrix);
355 else if (order == MatrixOrderPrepend)
356 matrix_multiply(shear, matrix->matrix, matrix->matrix);
357 else
358 return InvalidParameter;
359
360 return Ok;
361}

Referenced by test_font_transform(), and test_shear().

◆ GdipTransformMatrixPoints()

GpStatus WINGDIPAPI GdipTransformMatrixPoints ( GpMatrix matrix,
GpPointF pts,
INT  count 
)

Definition at line 363 of file matrix.c.

365{
366 REAL x, y;
367 INT i;
368
369 TRACE("(%p, %p, %d)\n", matrix, pts, count);
370
371 if(!matrix || !pts || count <= 0)
372 return InvalidParameter;
373
374 for(i = 0; i < count; i++)
375 {
376 x = pts[i].X;
377 y = pts[i].Y;
378
379 pts[i].X = x * matrix->matrix[0] + y * matrix->matrix[2] + matrix->matrix[4];
380 pts[i].Y = x * matrix->matrix[1] + y * matrix->matrix[3] + matrix->matrix[5];
381 }
382
383 return Ok;
384}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:58

Referenced by brush_fill_pixels(), draw_cap(), gdip_transform_points(), GdipDrawImagePointsRect(), GdipGetLogFontW(), GdipGetPathWorldBounds(), GdipMeasureDriverString(), GdipTransformMatrixPointsI(), GdipTransformPath(), get_font_hfont(), prepare_dc(), test_transform(), and transform_region_element().

◆ GdipTransformMatrixPointsI()

GpStatus WINGDIPAPI GdipTransformMatrixPointsI ( GpMatrix matrix,
GpPoint pts,
INT  count 
)

Definition at line 386 of file matrix.c.

387{
388 GpPointF *ptsF;
390 INT i;
391
392 TRACE("(%p, %p, %d)\n", matrix, pts, count);
393
394 if(count <= 0)
395 return InvalidParameter;
396
397 ptsF = heap_alloc_zero(sizeof(GpPointF) * count);
398 if(!ptsF)
399 return OutOfMemory;
400
401 for(i = 0; i < count; i++){
402 ptsF[i].X = (REAL)pts[i].X;
403 ptsF[i].Y = (REAL)pts[i].Y;
404 }
405
407
408 if(ret == Ok)
409 for(i = 0; i < count; i++){
410 pts[i].X = gdip_round(ptsF[i].X);
411 pts[i].Y = gdip_round(ptsF[i].Y);
412 }
413 heap_free(ptsF);
414
415 return ret;
416}
GpStatus WINGDIPAPI GdipTransformMatrixPoints(GpMatrix *matrix, GpPointF *pts, INT count)
Definition: matrix.c:363
static INT gdip_round(REAL x)
Status
Definition: gdiplustypes.h:25
int ret

◆ GdipTranslateMatrix()

GpStatus WINGDIPAPI GdipTranslateMatrix ( GpMatrix matrix,
REAL  offsetX,
REAL  offsetY,
GpMatrixOrder  order 
)

Definition at line 418 of file matrix.c.

420{
421 REAL translate[6];
422
423 TRACE("(%p, %.2f, %.2f, %d)\n", matrix, offsetX, offsetY, order);
424
425 if(!matrix)
426 return InvalidParameter;
427
428 translate[0] = 1.0;
429 translate[1] = 0.0;
430 translate[2] = 0.0;
431 translate[3] = 1.0;
432 translate[4] = offsetX;
433 translate[5] = offsetY;
434
436 matrix_multiply(matrix->matrix, translate, matrix->matrix);
437 else if (order == MatrixOrderPrepend)
438 matrix_multiply(translate, matrix->matrix, matrix->matrix);
439 else
440 return InvalidParameter;
441
442 return Ok;
443}
static void translate(POINT *pt, UINT count, const XFORM *xform)
Definition: metafile.c:2586

Referenced by draw_cap(), GdipPlayMetafileRecord(), GdipTranslateLineTransform(), GdipTranslatePathGradientTransform(), GdipTranslatePenTransform(), GdipTranslateTextureTransform(), GdipTranslateWorldTransform(), linegradient_init_transform(), test_clipping(), test_clipping_2(), and test_font_transform().

◆ GdipVectorTransformMatrixPoints()

GpStatus WINGDIPAPI GdipVectorTransformMatrixPoints ( GpMatrix matrix,
GpPointF pts,
INT  count 
)

Definition at line 445 of file matrix.c.

446{
447 REAL x, y;
448 INT i;
449
450 TRACE("(%p, %p, %d)\n", matrix, pts, count);
451
452 if(!matrix || !pts || count <= 0)
453 return InvalidParameter;
454
455 for(i = 0; i < count; i++)
456 {
457 x = pts[i].X;
458 y = pts[i].Y;
459
460 pts[i].X = x * matrix->matrix[0] + y * matrix->matrix[2];
461 pts[i].Y = x * matrix->matrix[1] + y * matrix->matrix[3];
462 }
463
464 return Ok;
465}

Referenced by GdipVectorTransformMatrixPointsI().

◆ GdipVectorTransformMatrixPointsI()

GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI ( GpMatrix matrix,
GpPoint pts,
INT  count 
)

Definition at line 467 of file matrix.c.

468{
469 GpPointF *ptsF;
471 INT i;
472
473 TRACE("(%p, %p, %d)\n", matrix, pts, count);
474
475 if(count <= 0)
476 return InvalidParameter;
477
478 ptsF = heap_alloc_zero(sizeof(GpPointF) * count);
479 if(!ptsF)
480 return OutOfMemory;
481
482 for(i = 0; i < count; i++){
483 ptsF[i].X = (REAL)pts[i].X;
484 ptsF[i].Y = (REAL)pts[i].Y;
485 }
486
488 /* store back */
489 if(ret == Ok)
490 for(i = 0; i < count; i++){
491 pts[i].X = gdip_round(ptsF[i].X);
492 pts[i].Y = gdip_round(ptsF[i].Y);
493 }
494 heap_free(ptsF);
495
496 return ret;
497}
GpStatus WINGDIPAPI GdipVectorTransformMatrixPoints(GpMatrix *matrix, GpPointF *pts, INT count)
Definition: matrix.c:445

◆ matrix_det()

static REAL matrix_det ( GDIPCONST GpMatrix matrix)
static

Definition at line 56 of file matrix.c.

57{
58 return matrix->matrix[0]*matrix->matrix[3] - matrix->matrix[1]*matrix->matrix[2];
59}

Referenced by GdipInvertMatrix(), and GdipIsMatrixInvertible().

◆ matrix_multiply()

static void matrix_multiply ( GDIPCONST REAL left,
GDIPCONST REAL right,
REAL out 
)
static

Definition at line 42 of file matrix.c.

43{
44 REAL temp[6];
45 int i, odd;
46
47 for(i = 0; i < 6; i++){
48 odd = i % 2;
49 temp[i] = left[i - odd] * right[odd] + left[i - odd + 1] * right[odd + 2] +
50 (i >= 4 ? right[odd + 4] : 0.0);
51 }
52
53 memcpy(out, temp, 6 * sizeof(REAL));
54}
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
#define odd(x)
Definition: bidi.c:51
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: unary.h:11

Referenced by GdipMultiplyMatrix(), GdipRotateMatrix(), GdipScaleMatrix(), GdipShearMatrix(), and GdipTranslateMatrix().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( gdiplus  )