Sync with trunk r58033.
[reactos.git] / dll / win32 / gdiplus / brush.c
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include <stdarg.h>
20
21 #include "windef.h"
22 #include "winbase.h"
23 #include "winuser.h"
24 #include "wingdi.h"
25
26 #define COBJMACROS
27 #include "objbase.h"
28 #include "olectl.h"
29 #include "ole2.h"
30
31 #include "gdiplus.h"
32 #include "gdiplus_private.h"
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
36
37 /*
38 Unix stuff
39 Code from http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/
40 */
41 double erf(double x)
42 {
43 const float a1 = 0.254829592;
44 const float a2 = -0.284496736;
45 const float a3 = 1.421413741;
46 const float a4 = -1.453152027;
47 const float a5 = 1.061405429;
48 const float p = 0.3275911;
49 float t, y, sign;
50
51 /* Save the sign of x */
52 sign = 1;
53 if (x < 0)
54 sign = -1;
55 x = abs(x);
56
57 /* A & S 7.1.26 */
58 t = 1.0/(1.0 + p*x);
59 y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);
60
61 return sign*y;
62 }
63
64 /******************************************************************************
65 * GdipCloneBrush [GDIPLUS.@]
66 */
67 GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
68 {
69 TRACE("(%p, %p)\n", brush, clone);
70
71 if(!brush || !clone)
72 return InvalidParameter;
73
74 switch(brush->bt){
75 case BrushTypeSolidColor:
76 {
77 *clone = GdipAlloc(sizeof(GpSolidFill));
78 if (!*clone) return OutOfMemory;
79 memcpy(*clone, brush, sizeof(GpSolidFill));
80 break;
81 }
82 case BrushTypeHatchFill:
83 {
84 GpHatch *hatch = (GpHatch*)brush;
85
86 return GdipCreateHatchBrush(hatch->hatchstyle, hatch->forecol, hatch->backcol, (GpHatch**)clone);
87 }
88 case BrushTypePathGradient:{
89 GpPathGradient *src, *dest;
90 INT count, pcount;
91 GpStatus stat;
92
93 *clone = GdipAlloc(sizeof(GpPathGradient));
94 if (!*clone) return OutOfMemory;
95
96 src = (GpPathGradient*) brush,
97 dest = (GpPathGradient*) *clone;
98
99 memcpy(dest, src, sizeof(GpPathGradient));
100
101 stat = GdipClonePath(src->path, &dest->path);
102
103 if(stat != Ok){
104 GdipFree(dest);
105 return stat;
106 }
107
108 dest->transform = src->transform;
109
110 /* blending */
111 count = src->blendcount;
112 dest->blendcount = count;
113 dest->blendfac = GdipAlloc(count * sizeof(REAL));
114 dest->blendpos = GdipAlloc(count * sizeof(REAL));
115 dest->surroundcolors = GdipAlloc(dest->surroundcolorcount * sizeof(ARGB));
116 pcount = dest->pblendcount;
117 if (pcount)
118 {
119 dest->pblendcolor = GdipAlloc(pcount * sizeof(ARGB));
120 dest->pblendpos = GdipAlloc(pcount * sizeof(REAL));
121 }
122
123 if(!dest->blendfac || !dest->blendpos || !dest->surroundcolors ||
124 (pcount && (!dest->pblendcolor || !dest->pblendpos))){
125 GdipDeletePath(dest->path);
126 GdipFree(dest->blendfac);
127 GdipFree(dest->blendpos);
128 GdipFree(dest->surroundcolors);
129 GdipFree(dest->pblendcolor);
130 GdipFree(dest->pblendpos);
131 GdipFree(dest);
132 return OutOfMemory;
133 }
134
135 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
136 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
137 memcpy(dest->surroundcolors, src->surroundcolors, dest->surroundcolorcount * sizeof(ARGB));
138
139 if (pcount)
140 {
141 memcpy(dest->pblendcolor, src->pblendcolor, pcount * sizeof(ARGB));
142 memcpy(dest->pblendpos, src->pblendpos, pcount * sizeof(REAL));
143 }
144
145 break;
146 }
147 case BrushTypeLinearGradient:{
148 GpLineGradient *dest, *src;
149 INT count, pcount;
150
151 dest = GdipAlloc(sizeof(GpLineGradient));
152 if(!dest) return OutOfMemory;
153
154 src = (GpLineGradient*)brush;
155
156 memcpy(dest, src, sizeof(GpLineGradient));
157
158 count = dest->blendcount;
159 dest->blendfac = GdipAlloc(count * sizeof(REAL));
160 dest->blendpos = GdipAlloc(count * sizeof(REAL));
161 pcount = dest->pblendcount;
162 if (pcount)
163 {
164 dest->pblendcolor = GdipAlloc(pcount * sizeof(ARGB));
165 dest->pblendpos = GdipAlloc(pcount * sizeof(REAL));
166 }
167
168 if (!dest->blendfac || !dest->blendpos ||
169 (pcount && (!dest->pblendcolor || !dest->pblendpos)))
170 {
171 GdipFree(dest->blendfac);
172 GdipFree(dest->blendpos);
173 GdipFree(dest->pblendcolor);
174 GdipFree(dest->pblendpos);
175 GdipFree(dest);
176 return OutOfMemory;
177 }
178
179 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
180 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
181
182 if (pcount)
183 {
184 memcpy(dest->pblendcolor, src->pblendcolor, pcount * sizeof(ARGB));
185 memcpy(dest->pblendpos, src->pblendpos, pcount * sizeof(REAL));
186 }
187
188 *clone = &dest->brush;
189 break;
190 }
191 case BrushTypeTextureFill:
192 {
193 GpStatus stat;
194 GpTexture *texture = (GpTexture*)brush;
195 GpTexture *new_texture;
196 UINT width, height;
197
198 stat = GdipGetImageWidth(texture->image, &width);
199 if (stat != Ok) return stat;
200 stat = GdipGetImageHeight(texture->image, &height);
201 if (stat != Ok) return stat;
202
203 stat = GdipCreateTextureIA(texture->image, texture->imageattributes, 0, 0, width, height, &new_texture);
204
205 if (stat == Ok)
206 {
207 new_texture->transform = texture->transform;
208 *clone = (GpBrush*)new_texture;
209 }
210 else
211 *clone = NULL;
212
213 return stat;
214 }
215 default:
216 ERR("not implemented for brush type %d\n", brush->bt);
217 return NotImplemented;
218 }
219
220 TRACE("<-- %p\n", *clone);
221 return Ok;
222 }
223
224 static const char HatchBrushes[][8] = {
225 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
226 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
227 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
228 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
229 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
230 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
231 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
232 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
233 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
234 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
235 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
236 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
237 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
238 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
239 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
240 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
241 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
242 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
243 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
244 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
245 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
246 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
247 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
248 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
249 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
250 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
251 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
252 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
253 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
254 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
255 };
256
257 GpStatus get_hatch_data(HatchStyle hatchstyle, const char **result)
258 {
259 if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
260 {
261 *result = HatchBrushes[hatchstyle];
262 return Ok;
263 }
264 else
265 return NotImplemented;
266 }
267
268 /******************************************************************************
269 * GdipCreateHatchBrush [GDIPLUS.@]
270 */
271 GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
272 {
273 TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);
274
275 if(!brush) return InvalidParameter;
276
277 *brush = GdipAlloc(sizeof(GpHatch));
278 if (!*brush) return OutOfMemory;
279
280 (*brush)->brush.bt = BrushTypeHatchFill;
281 (*brush)->forecol = forecol;
282 (*brush)->backcol = backcol;
283 (*brush)->hatchstyle = hatchstyle;
284 TRACE("<-- %p\n", *brush);
285
286 return Ok;
287 }
288
289 /******************************************************************************
290 * GdipCreateLineBrush [GDIPLUS.@]
291 */
292 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
293 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
294 GpWrapMode wrap, GpLineGradient **line)
295 {
296 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint),
297 debugstr_pointf(endpoint), startcolor, endcolor, wrap, line);
298
299 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
300 return InvalidParameter;
301
302 if (startpoint->X == endpoint->X && startpoint->Y == endpoint->Y)
303 return OutOfMemory;
304
305 *line = GdipAlloc(sizeof(GpLineGradient));
306 if(!*line) return OutOfMemory;
307
308 (*line)->brush.bt = BrushTypeLinearGradient;
309
310 (*line)->startpoint.X = startpoint->X;
311 (*line)->startpoint.Y = startpoint->Y;
312 (*line)->endpoint.X = endpoint->X;
313 (*line)->endpoint.Y = endpoint->Y;
314 (*line)->startcolor = startcolor;
315 (*line)->endcolor = endcolor;
316 (*line)->wrap = wrap;
317 (*line)->gamma = FALSE;
318
319 (*line)->rect.X = (startpoint->X < endpoint->X ? startpoint->X: endpoint->X);
320 (*line)->rect.Y = (startpoint->Y < endpoint->Y ? startpoint->Y: endpoint->Y);
321 (*line)->rect.Width = fabs(startpoint->X - endpoint->X);
322 (*line)->rect.Height = fabs(startpoint->Y - endpoint->Y);
323
324 if ((*line)->rect.Width == 0)
325 {
326 (*line)->rect.X -= (*line)->rect.Height / 2.0f;
327 (*line)->rect.Width = (*line)->rect.Height;
328 }
329 else if ((*line)->rect.Height == 0)
330 {
331 (*line)->rect.Y -= (*line)->rect.Width / 2.0f;
332 (*line)->rect.Height = (*line)->rect.Width;
333 }
334
335 (*line)->blendcount = 1;
336 (*line)->blendfac = GdipAlloc(sizeof(REAL));
337 (*line)->blendpos = GdipAlloc(sizeof(REAL));
338
339 if (!(*line)->blendfac || !(*line)->blendpos)
340 {
341 GdipFree((*line)->blendfac);
342 GdipFree((*line)->blendpos);
343 GdipFree(*line);
344 *line = NULL;
345 return OutOfMemory;
346 }
347
348 (*line)->blendfac[0] = 1.0f;
349 (*line)->blendpos[0] = 1.0f;
350
351 (*line)->pblendcolor = NULL;
352 (*line)->pblendpos = NULL;
353 (*line)->pblendcount = 0;
354
355 TRACE("<-- %p\n", *line);
356
357 return Ok;
358 }
359
360 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
361 GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
362 GpWrapMode wrap, GpLineGradient **line)
363 {
364 GpPointF stF;
365 GpPointF endF;
366
367 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
368 startcolor, endcolor, wrap, line);
369
370 if(!startpoint || !endpoint)
371 return InvalidParameter;
372
373 stF.X = (REAL)startpoint->X;
374 stF.Y = (REAL)startpoint->Y;
375 endF.X = (REAL)endpoint->X;
376 endF.Y = (REAL)endpoint->Y;
377
378 return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
379 }
380
381 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
382 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
383 GpLineGradient **line)
384 {
385 GpPointF start, end;
386 GpStatus stat;
387
388 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
389 wrap, line);
390
391 if(!line || !rect)
392 return InvalidParameter;
393
394 switch (mode)
395 {
396 case LinearGradientModeHorizontal:
397 start.X = rect->X;
398 start.Y = rect->Y;
399 end.X = rect->X + rect->Width;
400 end.Y = rect->Y;
401 break;
402 case LinearGradientModeVertical:
403 start.X = rect->X;
404 start.Y = rect->Y;
405 end.X = rect->X;
406 end.Y = rect->Y + rect->Height;
407 break;
408 case LinearGradientModeForwardDiagonal:
409 start.X = rect->X;
410 start.Y = rect->Y;
411 end.X = rect->X + rect->Width;
412 end.Y = rect->Y + rect->Height;
413 break;
414 case LinearGradientModeBackwardDiagonal:
415 start.X = rect->X + rect->Width;
416 start.Y = rect->Y;
417 end.X = rect->X;
418 end.Y = rect->Y + rect->Height;
419 break;
420 default:
421 return InvalidParameter;
422 }
423
424 stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
425
426 if (stat == Ok)
427 (*line)->rect = *rect;
428
429 return stat;
430 }
431
432 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
433 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
434 GpLineGradient **line)
435 {
436 GpRectF rectF;
437
438 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
439 wrap, line);
440
441 rectF.X = (REAL) rect->X;
442 rectF.Y = (REAL) rect->Y;
443 rectF.Width = (REAL) rect->Width;
444 rectF.Height = (REAL) rect->Height;
445
446 return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
447 }
448
449 /******************************************************************************
450 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
451 */
452 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
453 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
454 GpLineGradient **line)
455 {
456 GpStatus stat;
457 LinearGradientMode mode;
458 REAL width, height, exofs, eyofs;
459 REAL sin_angle, cos_angle, sin_cos_angle;
460
461 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
462 wrap, line);
463
464 sin_angle = sinf(deg2rad(angle));
465 cos_angle = cosf(deg2rad(angle));
466 sin_cos_angle = sin_angle * cos_angle;
467
468 if (isAngleScalable)
469 {
470 width = height = 1.0;
471 }
472 else
473 {
474 width = rect->Width;
475 height = rect->Height;
476 }
477
478 if (sin_cos_angle >= 0)
479 mode = LinearGradientModeForwardDiagonal;
480 else
481 mode = LinearGradientModeBackwardDiagonal;
482
483 stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);
484
485 if (stat == Ok)
486 {
487 if (sin_cos_angle >= 0)
488 {
489 exofs = width * sin_cos_angle + height * cos_angle * cos_angle;
490 eyofs = width * sin_angle * sin_angle + height * sin_cos_angle;
491 }
492 else
493 {
494 exofs = width * sin_angle * sin_angle + height * sin_cos_angle;
495 eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle;
496 }
497
498 if (isAngleScalable)
499 {
500 exofs = exofs * rect->Width;
501 eyofs = eyofs * rect->Height;
502 }
503
504 if (sin_angle >= 0)
505 {
506 (*line)->endpoint.X = rect->X + exofs;
507 (*line)->endpoint.Y = rect->Y + eyofs;
508 }
509 else
510 {
511 (*line)->endpoint.X = (*line)->startpoint.X;
512 (*line)->endpoint.Y = (*line)->startpoint.Y;
513 (*line)->startpoint.X = rect->X + exofs;
514 (*line)->startpoint.Y = rect->Y + eyofs;
515 }
516 }
517
518 return stat;
519 }
520
521 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
522 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
523 GpLineGradient **line)
524 {
525 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
526 wrap, line);
527
528 return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
529 wrap, line);
530 }
531
532 static GpStatus create_path_gradient(GpPath *path, ARGB centercolor, GpPathGradient **grad)
533 {
534 GpRectF bounds;
535
536 if(!path || !grad)
537 return InvalidParameter;
538
539 if (path->pathdata.Count < 2)
540 return OutOfMemory;
541
542 GdipGetPathWorldBounds(path, &bounds, NULL, NULL);
543
544 *grad = GdipAlloc(sizeof(GpPathGradient));
545 if (!*grad)
546 {
547 return OutOfMemory;
548 }
549
550 GdipSetMatrixElements(&(*grad)->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
551
552 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
553 (*grad)->blendpos = GdipAlloc(sizeof(REAL));
554 (*grad)->surroundcolors = GdipAlloc(sizeof(ARGB));
555 if(!(*grad)->blendfac || !(*grad)->blendpos || !(*grad)->surroundcolors){
556 GdipFree((*grad)->blendfac);
557 GdipFree((*grad)->blendpos);
558 GdipFree((*grad)->surroundcolors);
559 GdipFree(*grad);
560 *grad = NULL;
561 return OutOfMemory;
562 }
563 (*grad)->blendfac[0] = 1.0;
564 (*grad)->blendpos[0] = 1.0;
565 (*grad)->blendcount = 1;
566
567 (*grad)->path = path;
568
569 (*grad)->brush.bt = BrushTypePathGradient;
570 (*grad)->centercolor = centercolor;
571 (*grad)->wrap = WrapModeClamp;
572 (*grad)->gamma = FALSE;
573 /* FIXME: this should be set to the "centroid" of the path by default */
574 (*grad)->center.X = bounds.X + bounds.Width / 2;
575 (*grad)->center.Y = bounds.Y + bounds.Height / 2;
576 (*grad)->focus.X = 0.0;
577 (*grad)->focus.Y = 0.0;
578 (*grad)->surroundcolors[0] = 0xffffffff;
579 (*grad)->surroundcolorcount = 1;
580
581 TRACE("<-- %p\n", *grad);
582
583 return Ok;
584 }
585
586 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
587 INT count, GpWrapMode wrap, GpPathGradient **grad)
588 {
589 GpStatus stat;
590 GpPath *path;
591
592 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
593
594 if(!grad)
595 return InvalidParameter;
596
597 if(!points || count <= 0)
598 return OutOfMemory;
599
600 stat = GdipCreatePath(FillModeAlternate, &path);
601
602 if (stat == Ok)
603 {
604 stat = GdipAddPathLine2(path, points, count);
605
606 if (stat == Ok)
607 stat = create_path_gradient(path, 0xff000000, grad);
608
609 if (stat != Ok)
610 GdipDeletePath(path);
611 }
612
613 if (stat == Ok)
614 (*grad)->wrap = wrap;
615
616 return stat;
617 }
618
619 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
620 INT count, GpWrapMode wrap, GpPathGradient **grad)
621 {
622 GpStatus stat;
623 GpPath *path;
624
625 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
626
627 if(!grad)
628 return InvalidParameter;
629
630 if(!points || count <= 0)
631 return OutOfMemory;
632
633 stat = GdipCreatePath(FillModeAlternate, &path);
634
635 if (stat == Ok)
636 {
637 stat = GdipAddPathLine2I(path, points, count);
638
639 if (stat == Ok)
640 stat = create_path_gradient(path, 0xff000000, grad);
641
642 if (stat != Ok)
643 GdipDeletePath(path);
644 }
645
646 if (stat == Ok)
647 (*grad)->wrap = wrap;
648
649 return stat;
650 }
651
652 /******************************************************************************
653 * GdipCreatePathGradientFromPath [GDIPLUS.@]
654 */
655 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
656 GpPathGradient **grad)
657 {
658 GpStatus stat;
659 GpPath *new_path;
660
661 TRACE("(%p, %p)\n", path, grad);
662
663 if(!grad)
664 return InvalidParameter;
665
666 if (!path)
667 return OutOfMemory;
668
669 stat = GdipClonePath((GpPath*)path, &new_path);
670
671 if (stat == Ok)
672 {
673 stat = create_path_gradient(new_path, 0xffffffff, grad);
674
675 if (stat != Ok)
676 GdipDeletePath(new_path);
677 }
678
679 return stat;
680 }
681
682 /******************************************************************************
683 * GdipCreateSolidFill [GDIPLUS.@]
684 */
685 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
686 {
687 TRACE("(%x, %p)\n", color, sf);
688
689 if(!sf) return InvalidParameter;
690
691 *sf = GdipAlloc(sizeof(GpSolidFill));
692 if (!*sf) return OutOfMemory;
693
694 (*sf)->brush.bt = BrushTypeSolidColor;
695 (*sf)->color = color;
696
697 TRACE("<-- %p\n", *sf);
698
699 return Ok;
700 }
701
702 /******************************************************************************
703 * GdipCreateTexture [GDIPLUS.@]
704 *
705 * PARAMS
706 * image [I] image to use
707 * wrapmode [I] optional
708 * texture [O] pointer to the resulting texturebrush
709 *
710 * RETURNS
711 * SUCCESS: Ok
712 * FAILURE: element of GpStatus
713 */
714 GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
715 GpTexture **texture)
716 {
717 UINT width, height;
718 GpImageAttributes *attributes;
719 GpStatus stat;
720
721 TRACE("%p, %d %p\n", image, wrapmode, texture);
722
723 if (!(image && texture))
724 return InvalidParameter;
725
726 stat = GdipGetImageWidth(image, &width);
727 if (stat != Ok) return stat;
728 stat = GdipGetImageHeight(image, &height);
729 if (stat != Ok) return stat;
730
731 stat = GdipCreateImageAttributes(&attributes);
732
733 if (stat == Ok)
734 {
735 attributes->wrap = wrapmode;
736
737 stat = GdipCreateTextureIA(image, attributes, 0, 0, width, height,
738 texture);
739
740 GdipDisposeImageAttributes(attributes);
741 }
742
743 return stat;
744 }
745
746 /******************************************************************************
747 * GdipCreateTexture2 [GDIPLUS.@]
748 */
749 GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
750 REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
751 {
752 GpImageAttributes *attributes;
753 GpStatus stat;
754
755 TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
756 x, y, width, height, texture);
757
758 stat = GdipCreateImageAttributes(&attributes);
759
760 if (stat == Ok)
761 {
762 attributes->wrap = wrapmode;
763
764 stat = GdipCreateTextureIA(image, attributes, x, y, width, height,
765 texture);
766
767 GdipDisposeImageAttributes(attributes);
768 }
769
770 return stat;
771 }
772
773 /******************************************************************************
774 * GdipCreateTextureIA [GDIPLUS.@]
775 *
776 * FIXME: imageattr ignored
777 */
778 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
779 GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
780 REAL height, GpTexture **texture)
781 {
782 GpStatus status;
783 GpImage *new_image=NULL;
784
785 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
786 texture);
787
788 if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
789 return InvalidParameter;
790
791 *texture = NULL;
792
793 if(image->type != ImageTypeBitmap){
794 FIXME("not implemented for image type %d\n", image->type);
795 return NotImplemented;
796 }
797
798 status = GdipCloneBitmapArea(x, y, width, height, PixelFormatDontCare, (GpBitmap*)image, (GpBitmap**)&new_image);
799 if (status != Ok)
800 return status;
801
802 *texture = GdipAlloc(sizeof(GpTexture));
803 if (!*texture){
804 status = OutOfMemory;
805 goto exit;
806 }
807
808 GdipSetMatrixElements(&(*texture)->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
809
810 if (imageattr)
811 {
812 status = GdipCloneImageAttributes(imageattr, &(*texture)->imageattributes);
813 }
814 else
815 {
816 status = GdipCreateImageAttributes(&(*texture)->imageattributes);
817 if (status == Ok)
818 (*texture)->imageattributes->wrap = WrapModeTile;
819 }
820 if (status == Ok)
821 {
822 (*texture)->brush.bt = BrushTypeTextureFill;
823 (*texture)->image = new_image;
824 }
825
826 exit:
827 if (status == Ok)
828 {
829 TRACE("<-- %p\n", *texture);
830 }
831 else
832 {
833 if (*texture)
834 {
835 GdipDisposeImageAttributes((*texture)->imageattributes);
836 GdipFree(*texture);
837 *texture = NULL;
838 }
839 GdipDisposeImage(new_image);
840 TRACE("<-- error %u\n", status);
841 }
842
843 return status;
844 }
845
846 /******************************************************************************
847 * GdipCreateTextureIAI [GDIPLUS.@]
848 */
849 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
850 INT x, INT y, INT width, INT height, GpTexture **texture)
851 {
852 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
853 texture);
854
855 return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
856 }
857
858 GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
859 INT x, INT y, INT width, INT height, GpTexture **texture)
860 {
861 GpImageAttributes *imageattr;
862 GpStatus stat;
863
864 TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
865 texture);
866
867 stat = GdipCreateImageAttributes(&imageattr);
868
869 if (stat == Ok)
870 {
871 imageattr->wrap = wrapmode;
872
873 stat = GdipCreateTextureIA(image, imageattr, x, y, width, height, texture);
874 }
875
876 return stat;
877 }
878
879 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
880 {
881 TRACE("(%p, %p)\n", brush, type);
882
883 if(!brush || !type) return InvalidParameter;
884
885 *type = brush->bt;
886
887 return Ok;
888 }
889
890 GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
891 {
892 TRACE("(%p, %p)\n", brush, backcol);
893
894 if(!brush || !backcol) return InvalidParameter;
895
896 *backcol = brush->backcol;
897
898 return Ok;
899 }
900
901 GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
902 {
903 TRACE("(%p, %p)\n", brush, forecol);
904
905 if(!brush || !forecol) return InvalidParameter;
906
907 *forecol = brush->forecol;
908
909 return Ok;
910 }
911
912 GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
913 {
914 TRACE("(%p, %p)\n", brush, hatchstyle);
915
916 if(!brush || !hatchstyle) return InvalidParameter;
917
918 *hatchstyle = brush->hatchstyle;
919
920 return Ok;
921 }
922
923 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
924 {
925 TRACE("(%p)\n", brush);
926
927 if(!brush) return InvalidParameter;
928
929 switch(brush->bt)
930 {
931 case BrushTypePathGradient:
932 GdipDeletePath(((GpPathGradient*) brush)->path);
933 GdipFree(((GpPathGradient*) brush)->blendfac);
934 GdipFree(((GpPathGradient*) brush)->blendpos);
935 GdipFree(((GpPathGradient*) brush)->surroundcolors);
936 GdipFree(((GpPathGradient*) brush)->pblendcolor);
937 GdipFree(((GpPathGradient*) brush)->pblendpos);
938 break;
939 case BrushTypeLinearGradient:
940 GdipFree(((GpLineGradient*)brush)->blendfac);
941 GdipFree(((GpLineGradient*)brush)->blendpos);
942 GdipFree(((GpLineGradient*)brush)->pblendcolor);
943 GdipFree(((GpLineGradient*)brush)->pblendpos);
944 break;
945 case BrushTypeTextureFill:
946 GdipDisposeImage(((GpTexture*)brush)->image);
947 GdipDisposeImageAttributes(((GpTexture*)brush)->imageattributes);
948 GdipFree(((GpTexture*)brush)->bitmap_bits);
949 break;
950 default:
951 break;
952 }
953
954 GdipFree(brush);
955
956 return Ok;
957 }
958
959 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
960 BOOL *usinggamma)
961 {
962 TRACE("(%p, %p)\n", line, usinggamma);
963
964 if(!line || !usinggamma)
965 return InvalidParameter;
966
967 *usinggamma = line->gamma;
968
969 return Ok;
970 }
971
972 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
973 {
974 TRACE("(%p, %p)\n", brush, wrapmode);
975
976 if(!brush || !wrapmode)
977 return InvalidParameter;
978
979 *wrapmode = brush->wrap;
980
981 return Ok;
982 }
983
984 GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
985 REAL *positions, INT count)
986 {
987 TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);
988
989 if(!brush || !blend || !positions || count <= 0)
990 return InvalidParameter;
991
992 if(count < brush->blendcount)
993 return InsufficientBuffer;
994
995 memcpy(blend, brush->blendfac, count*sizeof(REAL));
996 if(brush->blendcount > 1){
997 memcpy(positions, brush->blendpos, count*sizeof(REAL));
998 }
999
1000 return Ok;
1001 }
1002
1003 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
1004 {
1005 TRACE("(%p, %p)\n", brush, count);
1006
1007 if(!brush || !count)
1008 return InvalidParameter;
1009
1010 *count = brush->blendcount;
1011
1012 return Ok;
1013 }
1014
1015 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
1016 GpPointF *point)
1017 {
1018 TRACE("(%p, %p)\n", grad, point);
1019
1020 if(!grad || !point)
1021 return InvalidParameter;
1022
1023 point->X = grad->center.X;
1024 point->Y = grad->center.Y;
1025
1026 return Ok;
1027 }
1028
1029 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
1030 GpPoint *point)
1031 {
1032 GpStatus ret;
1033 GpPointF ptf;
1034
1035 TRACE("(%p, %p)\n", grad, point);
1036
1037 if(!point)
1038 return InvalidParameter;
1039
1040 ret = GdipGetPathGradientCenterPoint(grad,&ptf);
1041
1042 if(ret == Ok){
1043 point->X = gdip_round(ptf.X);
1044 point->Y = gdip_round(ptf.Y);
1045 }
1046
1047 return ret;
1048 }
1049
1050 GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient *grad,
1051 ARGB *colors)
1052 {
1053 TRACE("(%p,%p)\n", grad, colors);
1054
1055 if (!grad || !colors)
1056 return InvalidParameter;
1057
1058 *colors = grad->centercolor;
1059
1060 return Ok;
1061 }
1062
1063 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
1064 REAL *x, REAL *y)
1065 {
1066 TRACE("(%p, %p, %p)\n", grad, x, y);
1067
1068 if(!grad || !x || !y)
1069 return InvalidParameter;
1070
1071 *x = grad->focus.X;
1072 *y = grad->focus.Y;
1073
1074 return Ok;
1075 }
1076
1077 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
1078 BOOL *gamma)
1079 {
1080 TRACE("(%p, %p)\n", grad, gamma);
1081
1082 if(!grad || !gamma)
1083 return InvalidParameter;
1084
1085 *gamma = grad->gamma;
1086
1087 return Ok;
1088 }
1089
1090 GpStatus WINGDIPAPI GdipGetPathGradientPath(GpPathGradient *grad, GpPath *path)
1091 {
1092 static int calls;
1093
1094 TRACE("(%p, %p)\n", grad, path);
1095
1096 if (!(calls++))
1097 FIXME("not implemented\n");
1098
1099 return NotImplemented;
1100 }
1101
1102 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
1103 INT *count)
1104 {
1105 TRACE("(%p, %p)\n", grad, count);
1106
1107 if(!grad || !count)
1108 return InvalidParameter;
1109
1110 *count = grad->path->pathdata.Count;
1111
1112 return Ok;
1113 }
1114
1115 GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
1116 {
1117 GpStatus stat;
1118
1119 TRACE("(%p, %p)\n", brush, rect);
1120
1121 if(!brush || !rect)
1122 return InvalidParameter;
1123
1124 stat = GdipGetPathWorldBounds(brush->path, rect, NULL, NULL);
1125
1126 return stat;
1127 }
1128
1129 GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
1130 {
1131 GpRectF rectf;
1132 GpStatus stat;
1133
1134 TRACE("(%p, %p)\n", brush, rect);
1135
1136 if(!brush || !rect)
1137 return InvalidParameter;
1138
1139 stat = GdipGetPathGradientRect(brush, &rectf);
1140 if(stat != Ok) return stat;
1141
1142 rect->X = gdip_round(rectf.X);
1143 rect->Y = gdip_round(rectf.Y);
1144 rect->Width = gdip_round(rectf.Width);
1145 rect->Height = gdip_round(rectf.Height);
1146
1147 return Ok;
1148 }
1149
1150 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1151 *grad, ARGB *argb, INT *count)
1152 {
1153 INT i;
1154
1155 TRACE("(%p,%p,%p)\n", grad, argb, count);
1156
1157 if(!grad || !argb || !count || (*count < grad->path->pathdata.Count))
1158 return InvalidParameter;
1159
1160 for (i=0; i<grad->path->pathdata.Count; i++)
1161 {
1162 if (i < grad->surroundcolorcount)
1163 argb[i] = grad->surroundcolors[i];
1164 else
1165 argb[i] = grad->surroundcolors[grad->surroundcolorcount-1];
1166 }
1167
1168 *count = grad->surroundcolorcount;
1169
1170 return Ok;
1171 }
1172
1173 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
1174 {
1175 TRACE("(%p, %p)\n", brush, count);
1176
1177 if (!brush || !count)
1178 return InvalidParameter;
1179
1180 /* Yes, this actually returns the number of points in the path (which is the
1181 * required size of a buffer to get the surround colors), rather than the
1182 * number of surround colors. The real count is returned when getting the
1183 * colors. */
1184 *count = brush->path->pathdata.Count;
1185
1186 return Ok;
1187 }
1188
1189 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
1190 GpWrapMode *wrapmode)
1191 {
1192 TRACE("(%p, %p)\n", brush, wrapmode);
1193
1194 if(!brush || !wrapmode)
1195 return InvalidParameter;
1196
1197 *wrapmode = brush->wrap;
1198
1199 return Ok;
1200 }
1201
1202 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
1203 {
1204 TRACE("(%p, %p)\n", sf, argb);
1205
1206 if(!sf || !argb)
1207 return InvalidParameter;
1208
1209 *argb = sf->color;
1210
1211 return Ok;
1212 }
1213
1214 /******************************************************************************
1215 * GdipGetTextureImage [GDIPLUS.@]
1216 */
1217 GpStatus WINGDIPAPI GdipGetTextureImage(GpTexture *brush, GpImage **image)
1218 {
1219 TRACE("(%p, %p)\n", brush, image);
1220
1221 if(!brush || !image)
1222 return InvalidParameter;
1223
1224 return GdipCloneImage(brush->image, image);
1225 }
1226
1227 /******************************************************************************
1228 * GdipGetTextureTransform [GDIPLUS.@]
1229 */
1230 GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
1231 {
1232 TRACE("(%p, %p)\n", brush, matrix);
1233
1234 if(!brush || !matrix)
1235 return InvalidParameter;
1236
1237 *matrix = brush->transform;
1238
1239 return Ok;
1240 }
1241
1242 /******************************************************************************
1243 * GdipGetTextureWrapMode [GDIPLUS.@]
1244 */
1245 GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
1246 {
1247 TRACE("(%p, %p)\n", brush, wrapmode);
1248
1249 if(!brush || !wrapmode)
1250 return InvalidParameter;
1251
1252 *wrapmode = brush->imageattributes->wrap;
1253
1254 return Ok;
1255 }
1256
1257 /******************************************************************************
1258 * GdipMultiplyTextureTransform [GDIPLUS.@]
1259 */
1260 GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
1261 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1262 {
1263 TRACE("(%p, %p, %d)\n", brush, matrix, order);
1264
1265 if(!brush || !matrix)
1266 return InvalidParameter;
1267
1268 return GdipMultiplyMatrix(&brush->transform, matrix, order);
1269 }
1270
1271 /******************************************************************************
1272 * GdipResetTextureTransform [GDIPLUS.@]
1273 */
1274 GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
1275 {
1276 TRACE("(%p)\n", brush);
1277
1278 if(!brush)
1279 return InvalidParameter;
1280
1281 return GdipSetMatrixElements(&brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1282 }
1283
1284 /******************************************************************************
1285 * GdipScaleTextureTransform [GDIPLUS.@]
1286 */
1287 GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
1288 REAL sx, REAL sy, GpMatrixOrder order)
1289 {
1290 TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);
1291
1292 if(!brush)
1293 return InvalidParameter;
1294
1295 return GdipScaleMatrix(&brush->transform, sx, sy, order);
1296 }
1297
1298 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
1299 GDIPCONST REAL *factors, GDIPCONST REAL* positions, INT count)
1300 {
1301 REAL *new_blendfac, *new_blendpos;
1302
1303 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1304
1305 if(!brush || !factors || !positions || count <= 0 ||
1306 (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
1307 return InvalidParameter;
1308
1309 new_blendfac = GdipAlloc(count * sizeof(REAL));
1310 new_blendpos = GdipAlloc(count * sizeof(REAL));
1311
1312 if (!new_blendfac || !new_blendpos)
1313 {
1314 GdipFree(new_blendfac);
1315 GdipFree(new_blendpos);
1316 return OutOfMemory;
1317 }
1318
1319 memcpy(new_blendfac, factors, count * sizeof(REAL));
1320 memcpy(new_blendpos, positions, count * sizeof(REAL));
1321
1322 GdipFree(brush->blendfac);
1323 GdipFree(brush->blendpos);
1324
1325 brush->blendcount = count;
1326 brush->blendfac = new_blendfac;
1327 brush->blendpos = new_blendpos;
1328
1329 return Ok;
1330 }
1331
1332 GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors,
1333 REAL *positions, INT count)
1334 {
1335 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1336
1337 if (!brush || !factors || !positions || count <= 0)
1338 return InvalidParameter;
1339
1340 if (count < brush->blendcount)
1341 return InsufficientBuffer;
1342
1343 memcpy(factors, brush->blendfac, brush->blendcount * sizeof(REAL));
1344 memcpy(positions, brush->blendpos, brush->blendcount * sizeof(REAL));
1345
1346 return Ok;
1347 }
1348
1349 GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
1350 {
1351 TRACE("(%p, %p)\n", brush, count);
1352
1353 if (!brush || !count)
1354 return InvalidParameter;
1355
1356 *count = brush->blendcount;
1357
1358 return Ok;
1359 }
1360
1361 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
1362 BOOL usegamma)
1363 {
1364 TRACE("(%p, %d)\n", line, usegamma);
1365
1366 if(!line)
1367 return InvalidParameter;
1368
1369 line->gamma = usegamma;
1370
1371 return Ok;
1372 }
1373
1374 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
1375 REAL scale)
1376 {
1377 REAL factors[33];
1378 REAL positions[33];
1379 int num_points = 0;
1380 int i;
1381 const int precision = 16;
1382 REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
1383 REAL min_erf;
1384 REAL scale_erf;
1385
1386 TRACE("(%p, %0.2f, %0.2f)\n", line, focus, scale);
1387
1388 if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1389 return InvalidParameter;
1390
1391 /* we want 2 standard deviations */
1392 erf_range = 2.0 / sqrt(2);
1393
1394 /* calculate the constants we need to normalize the error function to be
1395 between 0.0 and scale over the range we need */
1396 min_erf = erf(-erf_range);
1397 scale_erf = scale / (-2.0 * min_erf);
1398
1399 if (focus != 0.0)
1400 {
1401 positions[0] = 0.0;
1402 factors[0] = 0.0;
1403 for (i=1; i<precision; i++)
1404 {
1405 positions[i] = focus * i / precision;
1406 factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
1407 }
1408 num_points += precision;
1409 }
1410
1411 positions[num_points] = focus;
1412 factors[num_points] = scale;
1413 num_points += 1;
1414
1415 if (focus != 1.0)
1416 {
1417 for (i=1; i<precision; i++)
1418 {
1419 positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
1420 factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
1421 }
1422 num_points += precision;
1423 positions[num_points-1] = 1.0;
1424 factors[num_points-1] = 0.0;
1425 }
1426
1427 return GdipSetLineBlend(line, factors, positions, num_points);
1428 }
1429
1430 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
1431 GpWrapMode wrap)
1432 {
1433 TRACE("(%p, %d)\n", line, wrap);
1434
1435 if(!line || wrap == WrapModeClamp)
1436 return InvalidParameter;
1437
1438 line->wrap = wrap;
1439
1440 return Ok;
1441 }
1442
1443 GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
1444 GDIPCONST REAL *pos, INT count)
1445 {
1446 REAL *new_blendfac, *new_blendpos;
1447
1448 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1449
1450 if(!brush || !blend || !pos || count <= 0 ||
1451 (count >= 2 && (pos[0] != 0.0f || pos[count-1] != 1.0f)))
1452 return InvalidParameter;
1453
1454 new_blendfac = GdipAlloc(count * sizeof(REAL));
1455 new_blendpos = GdipAlloc(count * sizeof(REAL));
1456
1457 if (!new_blendfac || !new_blendpos)
1458 {
1459 GdipFree(new_blendfac);
1460 GdipFree(new_blendpos);
1461 return OutOfMemory;
1462 }
1463
1464 memcpy(new_blendfac, blend, count * sizeof(REAL));
1465 memcpy(new_blendpos, pos, count * sizeof(REAL));
1466
1467 GdipFree(brush->blendfac);
1468 GdipFree(brush->blendpos);
1469
1470 brush->blendcount = count;
1471 brush->blendfac = new_blendfac;
1472 brush->blendpos = new_blendpos;
1473
1474 return Ok;
1475 }
1476
1477 GpStatus WINGDIPAPI GdipSetPathGradientLinearBlend(GpPathGradient *brush,
1478 REAL focus, REAL scale)
1479 {
1480 REAL factors[3];
1481 REAL positions[3];
1482 int num_points = 0;
1483
1484 TRACE("(%p,%0.2f,%0.2f)\n", brush, focus, scale);
1485
1486 if (!brush) return InvalidParameter;
1487
1488 if (focus != 0.0)
1489 {
1490 factors[num_points] = 0.0;
1491 positions[num_points] = 0.0;
1492 num_points++;
1493 }
1494
1495 factors[num_points] = scale;
1496 positions[num_points] = focus;
1497 num_points++;
1498
1499 if (focus != 1.0)
1500 {
1501 factors[num_points] = 0.0;
1502 positions[num_points] = 1.0;
1503 num_points++;
1504 }
1505
1506 return GdipSetPathGradientBlend(brush, factors, positions, num_points);
1507 }
1508
1509 GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
1510 GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
1511 {
1512 ARGB *new_color;
1513 REAL *new_pos;
1514 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1515
1516 if (!brush || !blend || !pos || count < 2 ||
1517 pos[0] != 0.0f || pos[count-1] != 1.0f)
1518 {
1519 return InvalidParameter;
1520 }
1521
1522 new_color = GdipAlloc(count * sizeof(ARGB));
1523 new_pos = GdipAlloc(count * sizeof(REAL));
1524 if (!new_color || !new_pos)
1525 {
1526 GdipFree(new_color);
1527 GdipFree(new_pos);
1528 return OutOfMemory;
1529 }
1530
1531 memcpy(new_color, blend, sizeof(ARGB) * count);
1532 memcpy(new_pos, pos, sizeof(REAL) * count);
1533
1534 GdipFree(brush->pblendcolor);
1535 GdipFree(brush->pblendpos);
1536
1537 brush->pblendcolor = new_color;
1538 brush->pblendpos = new_pos;
1539 brush->pblendcount = count;
1540
1541 return Ok;
1542 }
1543
1544 GpStatus WINGDIPAPI GdipGetPathGradientPresetBlend(GpPathGradient *brush,
1545 ARGB *blend, REAL *pos, INT count)
1546 {
1547 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1548
1549 if (count < 0)
1550 return OutOfMemory;
1551
1552 if (!brush || !blend || !pos || count < 2)
1553 return InvalidParameter;
1554
1555 if (brush->pblendcount == 0)
1556 return GenericError;
1557
1558 if (count != brush->pblendcount)
1559 {
1560 /* Native lines up the ends of each array, and copies the destination size. */
1561 FIXME("Braindead behavior on wrong-sized buffer not implemented.\n");
1562 return InvalidParameter;
1563 }
1564
1565 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
1566 memcpy(pos, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
1567
1568 return Ok;
1569 }
1570
1571 GpStatus WINGDIPAPI GdipGetPathGradientPresetBlendCount(GpPathGradient *brush,
1572 INT *count)
1573 {
1574 TRACE("(%p,%p)\n", brush, count);
1575
1576 if (!brush || !count)
1577 return InvalidParameter;
1578
1579 *count = brush->pblendcount;
1580
1581 return Ok;
1582 }
1583
1584 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
1585 ARGB argb)
1586 {
1587 TRACE("(%p, %x)\n", grad, argb);
1588
1589 if(!grad)
1590 return InvalidParameter;
1591
1592 grad->centercolor = argb;
1593 return Ok;
1594 }
1595
1596 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
1597 GpPointF *point)
1598 {
1599 TRACE("(%p, %s)\n", grad, debugstr_pointf(point));
1600
1601 if(!grad || !point)
1602 return InvalidParameter;
1603
1604 grad->center.X = point->X;
1605 grad->center.Y = point->Y;
1606
1607 return Ok;
1608 }
1609
1610 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
1611 GpPoint *point)
1612 {
1613 GpPointF ptf;
1614
1615 TRACE("(%p, %p)\n", grad, point);
1616
1617 if(!point)
1618 return InvalidParameter;
1619
1620 ptf.X = (REAL)point->X;
1621 ptf.Y = (REAL)point->Y;
1622
1623 return GdipSetPathGradientCenterPoint(grad,&ptf);
1624 }
1625
1626 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
1627 REAL x, REAL y)
1628 {
1629 TRACE("(%p, %.2f, %.2f)\n", grad, x, y);
1630
1631 if(!grad)
1632 return InvalidParameter;
1633
1634 grad->focus.X = x;
1635 grad->focus.Y = y;
1636
1637 return Ok;
1638 }
1639
1640 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
1641 BOOL gamma)
1642 {
1643 TRACE("(%p, %d)\n", grad, gamma);
1644
1645 if(!grad)
1646 return InvalidParameter;
1647
1648 grad->gamma = gamma;
1649
1650 return Ok;
1651 }
1652
1653 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
1654 REAL focus, REAL scale)
1655 {
1656 REAL factors[33];
1657 REAL positions[33];
1658 int num_points = 0;
1659 int i;
1660 const int precision = 16;
1661 REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
1662 REAL min_erf;
1663 REAL scale_erf;
1664
1665 TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale);
1666
1667 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1668 return InvalidParameter;
1669
1670 /* we want 2 standard deviations */
1671 erf_range = 2.0 / sqrt(2);
1672
1673 /* calculate the constants we need to normalize the error function to be
1674 between 0.0 and scale over the range we need */
1675 min_erf = erf(-erf_range);
1676 scale_erf = scale / (-2.0 * min_erf);
1677
1678 if (focus != 0.0)
1679 {
1680 positions[0] = 0.0;
1681 factors[0] = 0.0;
1682 for (i=1; i<precision; i++)
1683 {
1684 positions[i] = focus * i / precision;
1685 factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
1686 }
1687 num_points += precision;
1688 }
1689
1690 positions[num_points] = focus;
1691 factors[num_points] = scale;
1692 num_points += 1;
1693
1694 if (focus != 1.0)
1695 {
1696 for (i=1; i<precision; i++)
1697 {
1698 positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
1699 factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
1700 }
1701 num_points += precision;
1702 positions[num_points-1] = 1.0;
1703 factors[num_points-1] = 0.0;
1704 }
1705
1706 return GdipSetPathGradientBlend(grad, factors, positions, num_points);
1707 }
1708
1709 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1710 *grad, GDIPCONST ARGB *argb, INT *count)
1711 {
1712 ARGB *new_surroundcolors;
1713 INT i, num_colors;
1714
1715 TRACE("(%p,%p,%p)\n", grad, argb, count);
1716
1717 if(!grad || !argb || !count || (*count <= 0) ||
1718 (*count > grad->path->pathdata.Count))
1719 return InvalidParameter;
1720
1721 num_colors = *count;
1722
1723 /* If all colors are the same, only store 1 color. */
1724 if (*count > 1)
1725 {
1726 for (i=1; i < num_colors; i++)
1727 if (argb[i] != argb[i-1])
1728 break;
1729
1730 if (i == num_colors)
1731 num_colors = 1;
1732 }
1733
1734 new_surroundcolors = GdipAlloc(num_colors * sizeof(ARGB));
1735 if (!new_surroundcolors)
1736 return OutOfMemory;
1737
1738 memcpy(new_surroundcolors, argb, num_colors * sizeof(ARGB));
1739
1740 GdipFree(grad->surroundcolors);
1741
1742 grad->surroundcolors = new_surroundcolors;
1743 grad->surroundcolorcount = num_colors;
1744
1745 return Ok;
1746 }
1747
1748 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
1749 GpWrapMode wrap)
1750 {
1751 TRACE("(%p, %d)\n", grad, wrap);
1752
1753 if(!grad)
1754 return InvalidParameter;
1755
1756 grad->wrap = wrap;
1757
1758 return Ok;
1759 }
1760
1761 GpStatus WINGDIPAPI GdipSetPathGradientTransform(GpPathGradient *grad,
1762 GpMatrix *matrix)
1763 {
1764 TRACE("(%p,%p)\n", grad, matrix);
1765
1766 if (!grad || !matrix)
1767 return InvalidParameter;
1768
1769 grad->transform = *matrix;
1770
1771 return Ok;
1772 }
1773
1774 GpStatus WINGDIPAPI GdipGetPathGradientTransform(GpPathGradient *grad,
1775 GpMatrix *matrix)
1776 {
1777 TRACE("(%p,%p)\n", grad, matrix);
1778
1779 if (!grad || !matrix)
1780 return InvalidParameter;
1781
1782 *matrix = grad->transform;
1783
1784 return Ok;
1785 }
1786
1787 GpStatus WINGDIPAPI GdipMultiplyPathGradientTransform(GpPathGradient *grad,
1788 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1789 {
1790 TRACE("(%p,%p,%i)\n", grad, matrix, order);
1791
1792 if (!grad)
1793 return InvalidParameter;
1794
1795 return GdipMultiplyMatrix(&grad->transform, matrix, order);
1796 }
1797
1798 GpStatus WINGDIPAPI GdipResetPathGradientTransform(GpPathGradient *grad)
1799 {
1800 TRACE("(%p)\n", grad);
1801
1802 if (!grad)
1803 return InvalidParameter;
1804
1805 return GdipSetMatrixElements(&grad->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1806 }
1807
1808 GpStatus WINGDIPAPI GdipRotatePathGradientTransform(GpPathGradient *grad,
1809 REAL angle, GpMatrixOrder order)
1810 {
1811 TRACE("(%p,%0.2f,%i)\n", grad, angle, order);
1812
1813 if (!grad)
1814 return InvalidParameter;
1815
1816 return GdipRotateMatrix(&grad->transform, angle, order);
1817 }
1818
1819 GpStatus WINGDIPAPI GdipScalePathGradientTransform(GpPathGradient *grad,
1820 REAL sx, REAL sy, GpMatrixOrder order)
1821 {
1822 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, sx, sy, order);
1823
1824 if (!grad)
1825 return InvalidParameter;
1826
1827 return GdipScaleMatrix(&grad->transform, sx, sy, order);
1828 }
1829
1830 GpStatus WINGDIPAPI GdipTranslatePathGradientTransform(GpPathGradient *grad,
1831 REAL dx, REAL dy, GpMatrixOrder order)
1832 {
1833 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, dx, dy, order);
1834
1835 if (!grad)
1836 return InvalidParameter;
1837
1838 return GdipTranslateMatrix(&grad->transform, dx, dy, order);
1839 }
1840
1841 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
1842 {
1843 TRACE("(%p, %x)\n", sf, argb);
1844
1845 if(!sf)
1846 return InvalidParameter;
1847
1848 sf->color = argb;
1849 return Ok;
1850 }
1851
1852 /******************************************************************************
1853 * GdipSetTextureTransform [GDIPLUS.@]
1854 */
1855 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
1856 GDIPCONST GpMatrix *matrix)
1857 {
1858 TRACE("(%p, %p)\n", texture, matrix);
1859
1860 if(!texture || !matrix)
1861 return InvalidParameter;
1862
1863 texture->transform = *matrix;
1864
1865 return Ok;
1866 }
1867
1868 /******************************************************************************
1869 * GdipSetTextureWrapMode [GDIPLUS.@]
1870 *
1871 * WrapMode not used, only stored
1872 */
1873 GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
1874 {
1875 TRACE("(%p, %d)\n", brush, wrapmode);
1876
1877 if(!brush)
1878 return InvalidParameter;
1879
1880 brush->imageattributes->wrap = wrapmode;
1881
1882 return Ok;
1883 }
1884
1885 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
1886 ARGB color2)
1887 {
1888 TRACE("(%p, %x, %x)\n", brush, color1, color2);
1889
1890 if(!brush)
1891 return InvalidParameter;
1892
1893 brush->startcolor = color1;
1894 brush->endcolor = color2;
1895
1896 return Ok;
1897 }
1898
1899 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
1900 {
1901 TRACE("(%p, %p)\n", brush, colors);
1902
1903 if(!brush || !colors)
1904 return InvalidParameter;
1905
1906 colors[0] = brush->startcolor;
1907 colors[1] = brush->endcolor;
1908
1909 return Ok;
1910 }
1911
1912 /******************************************************************************
1913 * GdipRotateTextureTransform [GDIPLUS.@]
1914 */
1915 GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
1916 GpMatrixOrder order)
1917 {
1918 TRACE("(%p, %.2f, %d)\n", brush, angle, order);
1919
1920 if(!brush)
1921 return InvalidParameter;
1922
1923 return GdipRotateMatrix(&brush->transform, angle, order);
1924 }
1925
1926 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
1927 REAL scale)
1928 {
1929 REAL factors[3];
1930 REAL positions[3];
1931 int num_points = 0;
1932
1933 TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
1934
1935 if (!brush) return InvalidParameter;
1936
1937 if (focus != 0.0)
1938 {
1939 factors[num_points] = 0.0;
1940 positions[num_points] = 0.0;
1941 num_points++;
1942 }
1943
1944 factors[num_points] = scale;
1945 positions[num_points] = focus;
1946 num_points++;
1947
1948 if (focus != 1.0)
1949 {
1950 factors[num_points] = 0.0;
1951 positions[num_points] = 1.0;
1952 num_points++;
1953 }
1954
1955 return GdipSetLineBlend(brush, factors, positions, num_points);
1956 }
1957
1958 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
1959 GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
1960 {
1961 ARGB *new_color;
1962 REAL *new_pos;
1963 TRACE("(%p,%p,%p,%i)\n", brush, blend, positions, count);
1964
1965 if (!brush || !blend || !positions || count < 2 ||
1966 positions[0] != 0.0f || positions[count-1] != 1.0f)
1967 {
1968 return InvalidParameter;
1969 }
1970
1971 new_color = GdipAlloc(count * sizeof(ARGB));
1972 new_pos = GdipAlloc(count * sizeof(REAL));
1973 if (!new_color || !new_pos)
1974 {
1975 GdipFree(new_color);
1976 GdipFree(new_pos);
1977 return OutOfMemory;
1978 }
1979
1980 memcpy(new_color, blend, sizeof(ARGB) * count);
1981 memcpy(new_pos, positions, sizeof(REAL) * count);
1982
1983 GdipFree(brush->pblendcolor);
1984 GdipFree(brush->pblendpos);
1985
1986 brush->pblendcolor = new_color;
1987 brush->pblendpos = new_pos;
1988 brush->pblendcount = count;
1989
1990 return Ok;
1991 }
1992
1993 GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush,
1994 ARGB *blend, REAL* positions, INT count)
1995 {
1996 if (!brush || !blend || !positions || count < 2)
1997 return InvalidParameter;
1998
1999 if (brush->pblendcount == 0)
2000 return GenericError;
2001
2002 if (count < brush->pblendcount)
2003 return InsufficientBuffer;
2004
2005 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
2006 memcpy(positions, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
2007
2008 return Ok;
2009 }
2010
2011 GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush,
2012 INT *count)
2013 {
2014 if (!brush || !count)
2015 return InvalidParameter;
2016
2017 *count = brush->pblendcount;
2018
2019 return Ok;
2020 }
2021
2022 GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
2023 {
2024 static int calls;
2025
2026 TRACE("(%p)\n", brush);
2027
2028 if(!(calls++))
2029 FIXME("not implemented\n");
2030
2031 return NotImplemented;
2032 }
2033
2034 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
2035 GDIPCONST GpMatrix *matrix)
2036 {
2037 static int calls;
2038
2039 TRACE("(%p,%p)\n", brush, matrix);
2040
2041 if(!(calls++))
2042 FIXME("not implemented\n");
2043
2044 return NotImplemented;
2045 }
2046
2047 GpStatus WINGDIPAPI GdipGetLineTransform(GpLineGradient *brush, GpMatrix *matrix)
2048 {
2049 static int calls;
2050
2051 TRACE("(%p,%p)\n", brush, matrix);
2052
2053 if(!(calls++))
2054 FIXME("not implemented\n");
2055
2056 return NotImplemented;
2057 }
2058
2059 GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy,
2060 GpMatrixOrder order)
2061 {
2062 static int calls;
2063
2064 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order);
2065
2066 if(!(calls++))
2067 FIXME("not implemented\n");
2068
2069 return NotImplemented;
2070 }
2071
2072 GpStatus WINGDIPAPI GdipMultiplyLineTransform(GpLineGradient *brush,
2073 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
2074 {
2075 static int calls;
2076
2077 TRACE("(%p,%p,%u)\n", brush, matrix, order);
2078
2079 if(!(calls++))
2080 FIXME("not implemented\n");
2081
2082 return NotImplemented;
2083 }
2084
2085 GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
2086 REAL dx, REAL dy, GpMatrixOrder order)
2087 {
2088 static int calls;
2089
2090 TRACE("(%p,%f,%f,%d)\n", brush, dx, dy, order);
2091
2092 if(!(calls++))
2093 FIXME("not implemented\n");
2094
2095 return Ok;
2096 }
2097
2098 /******************************************************************************
2099 * GdipTranslateTextureTransform [GDIPLUS.@]
2100 */
2101 GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
2102 GpMatrixOrder order)
2103 {
2104 TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);
2105
2106 if(!brush)
2107 return InvalidParameter;
2108
2109 return GdipTranslateMatrix(&brush->transform, dx, dy, order);
2110 }
2111
2112 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
2113 {
2114 TRACE("(%p, %p)\n", brush, rect);
2115
2116 if(!brush || !rect)
2117 return InvalidParameter;
2118
2119 *rect = brush->rect;
2120
2121 return Ok;
2122 }
2123
2124 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
2125 {
2126 GpRectF rectF;
2127 GpStatus ret;
2128
2129 TRACE("(%p, %p)\n", brush, rect);
2130
2131 if(!rect)
2132 return InvalidParameter;
2133
2134 ret = GdipGetLineRect(brush, &rectF);
2135
2136 if(ret == Ok){
2137 rect->X = gdip_round(rectF.X);
2138 rect->Y = gdip_round(rectF.Y);
2139 rect->Width = gdip_round(rectF.Width);
2140 rect->Height = gdip_round(rectF.Height);
2141 }
2142
2143 return ret;
2144 }
2145
2146 GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
2147 REAL angle, GpMatrixOrder order)
2148 {
2149 static int calls;
2150
2151 TRACE("(%p,%0.2f,%u)\n", brush, angle, order);
2152
2153 if(!brush)
2154 return InvalidParameter;
2155
2156 if(!(calls++))
2157 FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);
2158
2159 return NotImplemented;
2160 }