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