gdiplus: Add stub GdipGetPathGradientPath with tests.
[wine/multimedia.git] / dlls / gdiplus / brush.c
blobc601c1003a57ca362af8dd808c8616213d515e24
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
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.
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.
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
19 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "winuser.h"
24 #include "wingdi.h"
26 #define COBJMACROS
27 #include "objbase.h"
28 #include "olectl.h"
29 #include "ole2.h"
31 #include "gdiplus.h"
32 #include "gdiplus_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
37 /******************************************************************************
38 * GdipCloneBrush [GDIPLUS.@]
40 GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
42 TRACE("(%p, %p)\n", brush, clone);
44 if(!brush || !clone)
45 return InvalidParameter;
47 switch(brush->bt){
48 case BrushTypeSolidColor:
50 *clone = GdipAlloc(sizeof(GpSolidFill));
51 if (!*clone) return OutOfMemory;
52 memcpy(*clone, brush, sizeof(GpSolidFill));
53 break;
55 case BrushTypeHatchFill:
57 GpHatch *hatch = (GpHatch*)brush;
59 return GdipCreateHatchBrush(hatch->hatchstyle, hatch->forecol, hatch->backcol, (GpHatch**)clone);
61 case BrushTypePathGradient:{
62 GpPathGradient *src, *dest;
63 INT count;
64 GpStatus stat;
66 *clone = GdipAlloc(sizeof(GpPathGradient));
67 if (!*clone) return OutOfMemory;
69 src = (GpPathGradient*) brush,
70 dest = (GpPathGradient*) *clone;
72 memcpy(dest, src, sizeof(GpPathGradient));
74 stat = GdipClonePath(src->path, &dest->path);
76 if(stat != Ok){
77 GdipFree(dest);
78 return stat;
81 /* blending */
82 count = src->blendcount;
83 dest->blendcount = count;
84 dest->blendfac = GdipAlloc(count * sizeof(REAL));
85 dest->blendpos = GdipAlloc(count * sizeof(REAL));
87 if(!dest->blendfac || !dest->blendpos){
88 GdipDeletePath(dest->path);
89 GdipFree(dest->blendfac);
90 GdipFree(dest->blendpos);
91 GdipFree(dest);
92 return OutOfMemory;
95 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
96 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
98 break;
100 case BrushTypeLinearGradient:{
101 GpLineGradient *dest, *src;
102 INT count, pcount;
104 dest = GdipAlloc(sizeof(GpLineGradient));
105 if(!dest) return OutOfMemory;
107 src = (GpLineGradient*)brush;
109 memcpy(dest, src, sizeof(GpLineGradient));
111 count = dest->blendcount;
112 dest->blendfac = GdipAlloc(count * sizeof(REAL));
113 dest->blendpos = GdipAlloc(count * sizeof(REAL));
114 pcount = dest->pblendcount;
115 if (pcount)
117 dest->pblendcolor = GdipAlloc(pcount * sizeof(ARGB));
118 dest->pblendpos = GdipAlloc(pcount * sizeof(REAL));
121 if (!dest->blendfac || !dest->blendpos ||
122 (pcount && (!dest->pblendcolor || !dest->pblendpos)))
124 GdipFree(dest->blendfac);
125 GdipFree(dest->blendpos);
126 GdipFree(dest->pblendcolor);
127 GdipFree(dest->pblendpos);
128 GdipFree(dest);
129 return OutOfMemory;
132 memcpy(dest->blendfac, src->blendfac, count * sizeof(REAL));
133 memcpy(dest->blendpos, src->blendpos, count * sizeof(REAL));
135 if (pcount)
137 memcpy(dest->pblendcolor, src->pblendcolor, pcount * sizeof(ARGB));
138 memcpy(dest->pblendpos, src->pblendpos, pcount * sizeof(REAL));
141 *clone = &dest->brush;
142 break;
144 case BrushTypeTextureFill:
146 GpStatus stat;
147 GpTexture *texture = (GpTexture*)brush;
148 GpTexture *new_texture;
149 UINT width, height;
151 stat = GdipGetImageWidth(texture->image, &width);
152 if (stat != Ok) return stat;
153 stat = GdipGetImageHeight(texture->image, &height);
154 if (stat != Ok) return stat;
156 stat = GdipCreateTextureIA(texture->image, texture->imageattributes, 0, 0, width, height, &new_texture);
158 if (stat == Ok)
160 memcpy(new_texture->transform, texture->transform, sizeof(GpMatrix));
161 *clone = (GpBrush*)new_texture;
163 else
164 *clone = NULL;
166 return stat;
168 default:
169 ERR("not implemented for brush type %d\n", brush->bt);
170 return NotImplemented;
173 TRACE("<-- %p\n", *clone);
174 return Ok;
177 static const char HatchBrushes[][8] = {
178 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
179 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
180 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
181 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
182 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
183 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
184 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
185 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
186 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
187 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
188 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
189 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
190 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
191 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
192 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
193 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
194 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
195 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
196 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
197 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
198 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
199 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
200 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
201 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
202 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
203 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
204 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
205 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
206 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
207 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
210 GpStatus get_hatch_data(HatchStyle hatchstyle, const char **result)
212 if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0]))
214 *result = HatchBrushes[hatchstyle];
215 return Ok;
217 else
218 return NotImplemented;
221 /******************************************************************************
222 * GdipCreateHatchBrush [GDIPLUS.@]
224 GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
226 TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);
228 if(!brush) return InvalidParameter;
230 *brush = GdipAlloc(sizeof(GpHatch));
231 if (!*brush) return OutOfMemory;
233 (*brush)->brush.bt = BrushTypeHatchFill;
234 (*brush)->forecol = forecol;
235 (*brush)->backcol = backcol;
236 (*brush)->hatchstyle = hatchstyle;
237 TRACE("<-- %p\n", *brush);
239 return Ok;
242 /******************************************************************************
243 * GdipCreateLineBrush [GDIPLUS.@]
245 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
246 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
247 GpWrapMode wrap, GpLineGradient **line)
249 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint),
250 debugstr_pointf(endpoint), startcolor, endcolor, wrap, line);
252 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
253 return InvalidParameter;
255 if (startpoint->X == endpoint->X && startpoint->Y == endpoint->Y)
256 return OutOfMemory;
258 *line = GdipAlloc(sizeof(GpLineGradient));
259 if(!*line) return OutOfMemory;
261 (*line)->brush.bt = BrushTypeLinearGradient;
263 (*line)->startpoint.X = startpoint->X;
264 (*line)->startpoint.Y = startpoint->Y;
265 (*line)->endpoint.X = endpoint->X;
266 (*line)->endpoint.Y = endpoint->Y;
267 (*line)->startcolor = startcolor;
268 (*line)->endcolor = endcolor;
269 (*line)->wrap = wrap;
270 (*line)->gamma = FALSE;
272 (*line)->rect.X = (startpoint->X < endpoint->X ? startpoint->X: endpoint->X);
273 (*line)->rect.Y = (startpoint->Y < endpoint->Y ? startpoint->Y: endpoint->Y);
274 (*line)->rect.Width = fabs(startpoint->X - endpoint->X);
275 (*line)->rect.Height = fabs(startpoint->Y - endpoint->Y);
277 if ((*line)->rect.Width == 0)
279 (*line)->rect.X -= (*line)->rect.Height / 2.0f;
280 (*line)->rect.Width = (*line)->rect.Height;
282 else if ((*line)->rect.Height == 0)
284 (*line)->rect.Y -= (*line)->rect.Width / 2.0f;
285 (*line)->rect.Height = (*line)->rect.Width;
288 (*line)->blendcount = 1;
289 (*line)->blendfac = GdipAlloc(sizeof(REAL));
290 (*line)->blendpos = GdipAlloc(sizeof(REAL));
292 if (!(*line)->blendfac || !(*line)->blendpos)
294 GdipFree((*line)->blendfac);
295 GdipFree((*line)->blendpos);
296 GdipFree(*line);
297 *line = NULL;
298 return OutOfMemory;
301 (*line)->blendfac[0] = 1.0f;
302 (*line)->blendpos[0] = 1.0f;
304 (*line)->pblendcolor = NULL;
305 (*line)->pblendpos = NULL;
306 (*line)->pblendcount = 0;
308 TRACE("<-- %p\n", *line);
310 return Ok;
313 GpStatus WINGDIPAPI GdipCreateLineBrushI(GDIPCONST GpPoint* startpoint,
314 GDIPCONST GpPoint* endpoint, ARGB startcolor, ARGB endcolor,
315 GpWrapMode wrap, GpLineGradient **line)
317 GpPointF stF;
318 GpPointF endF;
320 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint, endpoint,
321 startcolor, endcolor, wrap, line);
323 if(!startpoint || !endpoint)
324 return InvalidParameter;
326 stF.X = (REAL)startpoint->X;
327 stF.Y = (REAL)startpoint->Y;
328 endF.X = (REAL)endpoint->X;
329 endF.Y = (REAL)endpoint->Y;
331 return GdipCreateLineBrush(&stF, &endF, startcolor, endcolor, wrap, line);
334 GpStatus WINGDIPAPI GdipCreateLineBrushFromRect(GDIPCONST GpRectF* rect,
335 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
336 GpLineGradient **line)
338 GpPointF start, end;
339 GpStatus stat;
341 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
342 wrap, line);
344 if(!line || !rect)
345 return InvalidParameter;
347 switch (mode)
349 case LinearGradientModeHorizontal:
350 start.X = rect->X;
351 start.Y = rect->Y;
352 end.X = rect->X + rect->Width;
353 end.Y = rect->Y;
354 break;
355 case LinearGradientModeVertical:
356 start.X = rect->X;
357 start.Y = rect->Y;
358 end.X = rect->X;
359 end.Y = rect->Y + rect->Height;
360 break;
361 case LinearGradientModeForwardDiagonal:
362 start.X = rect->X;
363 start.Y = rect->Y;
364 end.X = rect->X + rect->Width;
365 end.Y = rect->Y + rect->Height;
366 break;
367 case LinearGradientModeBackwardDiagonal:
368 start.X = rect->X + rect->Width;
369 start.Y = rect->Y;
370 end.X = rect->X;
371 end.Y = rect->Y + rect->Height;
372 break;
373 default:
374 return InvalidParameter;
377 stat = GdipCreateLineBrush(&start, &end, startcolor, endcolor, wrap, line);
379 if (stat == Ok)
380 (*line)->rect = *rect;
382 return stat;
385 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
386 ARGB startcolor, ARGB endcolor, LinearGradientMode mode, GpWrapMode wrap,
387 GpLineGradient **line)
389 GpRectF rectF;
391 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect, startcolor, endcolor, mode,
392 wrap, line);
394 rectF.X = (REAL) rect->X;
395 rectF.Y = (REAL) rect->Y;
396 rectF.Width = (REAL) rect->Width;
397 rectF.Height = (REAL) rect->Height;
399 return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
402 /******************************************************************************
403 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
405 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
406 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
407 GpLineGradient **line)
409 GpStatus stat;
410 LinearGradientMode mode;
411 REAL width, height, exofs, eyofs;
412 REAL sin_angle, cos_angle, sin_cos_angle;
414 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
415 wrap, line);
417 sin_angle = sinf(deg2rad(angle));
418 cos_angle = cosf(deg2rad(angle));
419 sin_cos_angle = sin_angle * cos_angle;
421 if (isAngleScalable)
423 width = height = 1.0;
425 else
427 width = rect->Width;
428 height = rect->Height;
431 if (sin_cos_angle >= 0)
432 mode = LinearGradientModeForwardDiagonal;
433 else
434 mode = LinearGradientModeBackwardDiagonal;
436 stat = GdipCreateLineBrushFromRect(rect, startcolor, endcolor, mode, wrap, line);
438 if (stat == Ok)
440 if (sin_cos_angle >= 0)
442 exofs = width * sin_cos_angle + height * cos_angle * cos_angle;
443 eyofs = width * sin_angle * sin_angle + height * sin_cos_angle;
445 else
447 exofs = width * sin_angle * sin_angle + height * sin_cos_angle;
448 eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle;
451 if (isAngleScalable)
453 exofs = exofs * rect->Width;
454 eyofs = eyofs * rect->Height;
457 if (sin_angle >= 0)
459 (*line)->endpoint.X = rect->X + exofs;
460 (*line)->endpoint.Y = rect->Y + eyofs;
462 else
464 (*line)->endpoint.X = (*line)->startpoint.X;
465 (*line)->endpoint.Y = (*line)->startpoint.Y;
466 (*line)->startpoint.X = rect->X + exofs;
467 (*line)->startpoint.Y = rect->Y + eyofs;
471 return stat;
474 GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect* rect,
475 ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
476 GpLineGradient **line)
478 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
479 wrap, line);
481 return GdipCreateLineBrushFromRectI(rect, startcolor, endcolor, LinearGradientModeForwardDiagonal,
482 wrap, line);
485 static GpStatus create_path_gradient(GpPath *path, GpPathGradient **grad)
487 if(!path || !grad)
488 return InvalidParameter;
490 *grad = GdipAlloc(sizeof(GpPathGradient));
491 if (!*grad)
493 return OutOfMemory;
496 (*grad)->blendfac = GdipAlloc(sizeof(REAL));
497 (*grad)->blendpos = GdipAlloc(sizeof(REAL));
498 if(!(*grad)->blendfac || !(*grad)->blendpos){
499 GdipFree((*grad)->blendfac);
500 GdipFree((*grad)->blendpos);
501 GdipFree(*grad);
502 *grad = NULL;
503 return OutOfMemory;
505 (*grad)->blendfac[0] = 1.0;
506 (*grad)->blendpos[0] = 1.0;
507 (*grad)->blendcount = 1;
509 (*grad)->path = path;
511 (*grad)->brush.bt = BrushTypePathGradient;
512 (*grad)->centercolor = 0xffffffff;
513 (*grad)->wrap = WrapModeClamp;
514 (*grad)->gamma = FALSE;
515 /* FIXME: this should be set to the "centroid" of the path by default */
516 (*grad)->center.X = 0.0;
517 (*grad)->center.Y = 0.0;
518 (*grad)->focus.X = 0.0;
519 (*grad)->focus.Y = 0.0;
521 TRACE("<-- %p\n", *grad);
523 return Ok;
526 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
527 INT count, GpWrapMode wrap, GpPathGradient **grad)
529 GpStatus stat;
530 GpPath *path;
532 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
534 if(!points || !grad)
535 return InvalidParameter;
537 if(count <= 0)
538 return OutOfMemory;
540 stat = GdipCreatePath(FillModeAlternate, &path);
542 if (stat == Ok)
544 stat = GdipAddPathLine2(path, points, count);
546 if (stat == Ok)
547 stat = create_path_gradient(path, grad);
549 if (stat != Ok)
550 GdipDeletePath(path);
553 return stat;
556 GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
557 INT count, GpWrapMode wrap, GpPathGradient **grad)
559 GpStatus stat;
560 GpPath *path;
562 TRACE("(%p, %d, %d, %p)\n", points, count, wrap, grad);
564 if(!points || !grad)
565 return InvalidParameter;
567 if(count <= 0)
568 return OutOfMemory;
570 stat = GdipCreatePath(FillModeAlternate, &path);
572 if (stat == Ok)
574 stat = GdipAddPathLine2I(path, points, count);
576 if (stat == Ok)
577 stat = create_path_gradient(path, grad);
579 if (stat != Ok)
580 GdipDeletePath(path);
583 return stat;
586 /******************************************************************************
587 * GdipCreatePathGradientFromPath [GDIPLUS.@]
589 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
590 GpPathGradient **grad)
592 GpStatus stat;
593 GpPath *new_path;
595 TRACE("(%p, %p)\n", path, grad);
597 if(!path || !grad)
598 return InvalidParameter;
600 stat = GdipClonePath((GpPath*)path, &new_path);
602 if (stat == Ok)
604 stat = create_path_gradient(new_path, grad);
606 if (stat != Ok)
607 GdipDeletePath(new_path);
610 return stat;
613 /******************************************************************************
614 * GdipCreateSolidFill [GDIPLUS.@]
616 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
618 TRACE("(%x, %p)\n", color, sf);
620 if(!sf) return InvalidParameter;
622 *sf = GdipAlloc(sizeof(GpSolidFill));
623 if (!*sf) return OutOfMemory;
625 (*sf)->brush.bt = BrushTypeSolidColor;
626 (*sf)->color = color;
628 TRACE("<-- %p\n", *sf);
630 return Ok;
633 /******************************************************************************
634 * GdipCreateTexture [GDIPLUS.@]
636 * PARAMS
637 * image [I] image to use
638 * wrapmode [I] optional
639 * texture [O] pointer to the resulting texturebrush
641 * RETURNS
642 * SUCCESS: Ok
643 * FAILURE: element of GpStatus
645 GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
646 GpTexture **texture)
648 UINT width, height;
649 GpImageAttributes *attributes;
650 GpStatus stat;
652 TRACE("%p, %d %p\n", image, wrapmode, texture);
654 if (!(image && texture))
655 return InvalidParameter;
657 stat = GdipGetImageWidth(image, &width);
658 if (stat != Ok) return stat;
659 stat = GdipGetImageHeight(image, &height);
660 if (stat != Ok) return stat;
662 stat = GdipCreateImageAttributes(&attributes);
664 if (stat == Ok)
666 attributes->wrap = wrapmode;
668 stat = GdipCreateTextureIA(image, attributes, 0, 0, width, height,
669 texture);
671 GdipDisposeImageAttributes(attributes);
674 return stat;
677 /******************************************************************************
678 * GdipCreateTexture2 [GDIPLUS.@]
680 GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
681 REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
683 GpImageAttributes *attributes;
684 GpStatus stat;
686 TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
687 x, y, width, height, texture);
689 stat = GdipCreateImageAttributes(&attributes);
691 if (stat == Ok)
693 attributes->wrap = wrapmode;
695 stat = GdipCreateTextureIA(image, attributes, x, y, width, height,
696 texture);
698 GdipDisposeImageAttributes(attributes);
701 return stat;
704 /******************************************************************************
705 * GdipCreateTextureIA [GDIPLUS.@]
707 * FIXME: imageattr ignored
709 GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
710 GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
711 REAL height, GpTexture **texture)
713 GpStatus status;
714 GpImage *new_image=NULL;
716 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
717 texture);
719 if(!image || !texture || x < 0.0 || y < 0.0 || width < 0.0 || height < 0.0)
720 return InvalidParameter;
722 *texture = NULL;
724 if(image->type != ImageTypeBitmap){
725 FIXME("not implemented for image type %d\n", image->type);
726 return NotImplemented;
729 status = GdipCloneBitmapArea(x, y, width, height, PixelFormatDontCare, (GpBitmap*)image, (GpBitmap**)&new_image);
730 if (status != Ok)
731 return status;
733 *texture = GdipAlloc(sizeof(GpTexture));
734 if (!*texture){
735 status = OutOfMemory;
736 goto exit;
739 if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
740 goto exit;
743 if (imageattr)
745 status = GdipCloneImageAttributes(imageattr, &(*texture)->imageattributes);
747 else
749 status = GdipCreateImageAttributes(&(*texture)->imageattributes);
750 if (status == Ok)
751 (*texture)->imageattributes->wrap = WrapModeTile;
753 if (status == Ok)
755 (*texture)->brush.bt = BrushTypeTextureFill;
756 (*texture)->image = new_image;
759 exit:
760 if (status == Ok)
762 TRACE("<-- %p\n", *texture);
764 else
766 if (*texture)
768 GdipDeleteMatrix((*texture)->transform);
769 GdipDisposeImageAttributes((*texture)->imageattributes);
770 GdipFree(*texture);
771 *texture = NULL;
773 GdipDisposeImage(new_image);
774 TRACE("<-- error %u\n", status);
777 return status;
780 /******************************************************************************
781 * GdipCreateTextureIAI [GDIPLUS.@]
783 GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
784 INT x, INT y, INT width, INT height, GpTexture **texture)
786 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image, imageattr, x, y, width, height,
787 texture);
789 return GdipCreateTextureIA(image,imageattr,(REAL)x,(REAL)y,(REAL)width,(REAL)height,texture);
792 GpStatus WINGDIPAPI GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode,
793 INT x, INT y, INT width, INT height, GpTexture **texture)
795 GpImageAttributes *imageattr;
796 GpStatus stat;
798 TRACE("%p %d %d %d %d %d %p\n", image, wrapmode, x, y, width, height,
799 texture);
801 stat = GdipCreateImageAttributes(&imageattr);
803 if (stat == Ok)
805 imageattr->wrap = wrapmode;
807 stat = GdipCreateTextureIA(image, imageattr, x, y, width, height, texture);
810 return stat;
813 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
815 TRACE("(%p, %p)\n", brush, type);
817 if(!brush || !type) return InvalidParameter;
819 *type = brush->bt;
821 return Ok;
824 GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
826 TRACE("(%p, %p)\n", brush, backcol);
828 if(!brush || !backcol) return InvalidParameter;
830 *backcol = brush->backcol;
832 return Ok;
835 GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
837 TRACE("(%p, %p)\n", brush, forecol);
839 if(!brush || !forecol) return InvalidParameter;
841 *forecol = brush->forecol;
843 return Ok;
846 GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
848 TRACE("(%p, %p)\n", brush, hatchstyle);
850 if(!brush || !hatchstyle) return InvalidParameter;
852 *hatchstyle = brush->hatchstyle;
854 return Ok;
857 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
859 TRACE("(%p)\n", brush);
861 if(!brush) return InvalidParameter;
863 switch(brush->bt)
865 case BrushTypePathGradient:
866 GdipDeletePath(((GpPathGradient*) brush)->path);
867 GdipFree(((GpPathGradient*) brush)->blendfac);
868 GdipFree(((GpPathGradient*) brush)->blendpos);
869 break;
870 case BrushTypeLinearGradient:
871 GdipFree(((GpLineGradient*)brush)->blendfac);
872 GdipFree(((GpLineGradient*)brush)->blendpos);
873 GdipFree(((GpLineGradient*)brush)->pblendcolor);
874 GdipFree(((GpLineGradient*)brush)->pblendpos);
875 break;
876 case BrushTypeTextureFill:
877 GdipDeleteMatrix(((GpTexture*)brush)->transform);
878 GdipDisposeImage(((GpTexture*)brush)->image);
879 GdipDisposeImageAttributes(((GpTexture*)brush)->imageattributes);
880 GdipFree(((GpTexture*)brush)->bitmap_bits);
881 break;
882 default:
883 break;
886 GdipFree(brush);
888 return Ok;
891 GpStatus WINGDIPAPI GdipGetLineGammaCorrection(GpLineGradient *line,
892 BOOL *usinggamma)
894 TRACE("(%p, %p)\n", line, usinggamma);
896 if(!line || !usinggamma)
897 return InvalidParameter;
899 *usinggamma = line->gamma;
901 return Ok;
904 GpStatus WINGDIPAPI GdipGetLineWrapMode(GpLineGradient *brush, GpWrapMode *wrapmode)
906 TRACE("(%p, %p)\n", brush, wrapmode);
908 if(!brush || !wrapmode)
909 return InvalidParameter;
911 *wrapmode = brush->wrap;
913 return Ok;
916 GpStatus WINGDIPAPI GdipGetPathGradientBlend(GpPathGradient *brush, REAL *blend,
917 REAL *positions, INT count)
919 TRACE("(%p, %p, %p, %d)\n", brush, blend, positions, count);
921 if(!brush || !blend || !positions || count <= 0)
922 return InvalidParameter;
924 if(count < brush->blendcount)
925 return InsufficientBuffer;
927 memcpy(blend, brush->blendfac, count*sizeof(REAL));
928 if(brush->blendcount > 1){
929 memcpy(positions, brush->blendpos, count*sizeof(REAL));
932 return Ok;
935 GpStatus WINGDIPAPI GdipGetPathGradientBlendCount(GpPathGradient *brush, INT *count)
937 TRACE("(%p, %p)\n", brush, count);
939 if(!brush || !count)
940 return InvalidParameter;
942 *count = brush->blendcount;
944 return Ok;
947 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
948 GpPointF *point)
950 TRACE("(%p, %p)\n", grad, point);
952 if(!grad || !point)
953 return InvalidParameter;
955 point->X = grad->center.X;
956 point->Y = grad->center.Y;
958 return Ok;
961 GpStatus WINGDIPAPI GdipGetPathGradientCenterPointI(GpPathGradient *grad,
962 GpPoint *point)
964 GpStatus ret;
965 GpPointF ptf;
967 TRACE("(%p, %p)\n", grad, point);
969 if(!point)
970 return InvalidParameter;
972 ret = GdipGetPathGradientCenterPoint(grad,&ptf);
974 if(ret == Ok){
975 point->X = roundr(ptf.X);
976 point->Y = roundr(ptf.Y);
979 return ret;
982 GpStatus WINGDIPAPI GdipGetPathGradientCenterColor(GpPathGradient *grad,
983 ARGB *colors)
985 static int calls;
987 TRACE("(%p,%p)\n", grad, colors);
989 if(!(calls++))
990 FIXME("not implemented\n");
992 return NotImplemented;
995 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
996 REAL *x, REAL *y)
998 TRACE("(%p, %p, %p)\n", grad, x, y);
1000 if(!grad || !x || !y)
1001 return InvalidParameter;
1003 *x = grad->focus.X;
1004 *y = grad->focus.Y;
1006 return Ok;
1009 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
1010 BOOL *gamma)
1012 TRACE("(%p, %p)\n", grad, gamma);
1014 if(!grad || !gamma)
1015 return InvalidParameter;
1017 *gamma = grad->gamma;
1019 return Ok;
1022 GpStatus WINGDIPAPI GdipGetPathGradientPath(GpPathGradient *grad, GpPath *path)
1024 static int calls;
1026 TRACE("(%p, %p)\n", grad, path);
1028 if (!(calls++))
1029 FIXME("not implemented\n");
1031 return NotImplemented;
1034 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
1035 INT *count)
1037 TRACE("(%p, %p)\n", grad, count);
1039 if(!grad || !count)
1040 return InvalidParameter;
1042 *count = grad->path->pathdata.Count;
1044 return Ok;
1047 GpStatus WINGDIPAPI GdipGetPathGradientRect(GpPathGradient *brush, GpRectF *rect)
1049 GpStatus stat;
1051 TRACE("(%p, %p)\n", brush, rect);
1053 if(!brush || !rect)
1054 return InvalidParameter;
1056 stat = GdipGetPathWorldBounds(brush->path, rect, NULL, NULL);
1058 return stat;
1061 GpStatus WINGDIPAPI GdipGetPathGradientRectI(GpPathGradient *brush, GpRect *rect)
1063 GpRectF rectf;
1064 GpStatus stat;
1066 TRACE("(%p, %p)\n", brush, rect);
1068 if(!brush || !rect)
1069 return InvalidParameter;
1071 stat = GdipGetPathGradientRect(brush, &rectf);
1072 if(stat != Ok) return stat;
1074 rect->X = roundr(rectf.X);
1075 rect->Y = roundr(rectf.Y);
1076 rect->Width = roundr(rectf.Width);
1077 rect->Height = roundr(rectf.Height);
1079 return Ok;
1082 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1083 *grad, ARGB *argb, INT *count)
1085 static int calls;
1087 TRACE("(%p,%p,%p)\n", grad, argb, count);
1089 if(!grad || !argb || !count || (*count < grad->path->pathdata.Count))
1090 return InvalidParameter;
1092 if(!(calls++))
1093 FIXME("not implemented\n");
1095 return NotImplemented;
1098 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorCount(GpPathGradient *brush, INT *count)
1100 static int calls;
1102 TRACE("(%p, %p)\n", brush, count);
1104 if (!brush || !count)
1105 return InvalidParameter;
1107 if(!(calls++))
1108 FIXME("not implemented\n");
1110 return NotImplemented;
1113 GpStatus WINGDIPAPI GdipGetPathGradientWrapMode(GpPathGradient *brush,
1114 GpWrapMode *wrapmode)
1116 TRACE("(%p, %p)\n", brush, wrapmode);
1118 if(!brush || !wrapmode)
1119 return InvalidParameter;
1121 *wrapmode = brush->wrap;
1123 return Ok;
1126 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
1128 TRACE("(%p, %p)\n", sf, argb);
1130 if(!sf || !argb)
1131 return InvalidParameter;
1133 *argb = sf->color;
1135 return Ok;
1138 /******************************************************************************
1139 * GdipGetTextureImage [GDIPLUS.@]
1141 GpStatus WINGDIPAPI GdipGetTextureImage(GpTexture *brush, GpImage **image)
1143 TRACE("(%p, %p)\n", brush, image);
1145 if(!brush || !image)
1146 return InvalidParameter;
1148 return GdipCloneImage(brush->image, image);
1151 /******************************************************************************
1152 * GdipGetTextureTransform [GDIPLUS.@]
1154 GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
1156 TRACE("(%p, %p)\n", brush, matrix);
1158 if(!brush || !matrix)
1159 return InvalidParameter;
1161 memcpy(matrix, brush->transform, sizeof(GpMatrix));
1163 return Ok;
1166 /******************************************************************************
1167 * GdipGetTextureWrapMode [GDIPLUS.@]
1169 GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
1171 TRACE("(%p, %p)\n", brush, wrapmode);
1173 if(!brush || !wrapmode)
1174 return InvalidParameter;
1176 *wrapmode = brush->imageattributes->wrap;
1178 return Ok;
1181 /******************************************************************************
1182 * GdipMultiplyTextureTransform [GDIPLUS.@]
1184 GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
1185 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1187 TRACE("(%p, %p, %d)\n", brush, matrix, order);
1189 if(!brush || !matrix)
1190 return InvalidParameter;
1192 return GdipMultiplyMatrix(brush->transform, matrix, order);
1195 /******************************************************************************
1196 * GdipResetTextureTransform [GDIPLUS.@]
1198 GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
1200 TRACE("(%p)\n", brush);
1202 if(!brush)
1203 return InvalidParameter;
1205 return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1208 /******************************************************************************
1209 * GdipScaleTextureTransform [GDIPLUS.@]
1211 GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
1212 REAL sx, REAL sy, GpMatrixOrder order)
1214 TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);
1216 if(!brush)
1217 return InvalidParameter;
1219 return GdipScaleMatrix(brush->transform, sx, sy, order);
1222 GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
1223 GDIPCONST REAL *factors, GDIPCONST REAL* positions, INT count)
1225 REAL *new_blendfac, *new_blendpos;
1227 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1229 if(!brush || !factors || !positions || count <= 0 ||
1230 (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
1231 return InvalidParameter;
1233 new_blendfac = GdipAlloc(count * sizeof(REAL));
1234 new_blendpos = GdipAlloc(count * sizeof(REAL));
1236 if (!new_blendfac || !new_blendpos)
1238 GdipFree(new_blendfac);
1239 GdipFree(new_blendpos);
1240 return OutOfMemory;
1243 memcpy(new_blendfac, factors, count * sizeof(REAL));
1244 memcpy(new_blendpos, positions, count * sizeof(REAL));
1246 GdipFree(brush->blendfac);
1247 GdipFree(brush->blendpos);
1249 brush->blendcount = count;
1250 brush->blendfac = new_blendfac;
1251 brush->blendpos = new_blendpos;
1253 return Ok;
1256 GpStatus WINGDIPAPI GdipGetLineBlend(GpLineGradient *brush, REAL *factors,
1257 REAL *positions, INT count)
1259 TRACE("(%p, %p, %p, %i)\n", brush, factors, positions, count);
1261 if (!brush || !factors || !positions || count <= 0)
1262 return InvalidParameter;
1264 if (count < brush->blendcount)
1265 return InsufficientBuffer;
1267 memcpy(factors, brush->blendfac, brush->blendcount * sizeof(REAL));
1268 memcpy(positions, brush->blendpos, brush->blendcount * sizeof(REAL));
1270 return Ok;
1273 GpStatus WINGDIPAPI GdipGetLineBlendCount(GpLineGradient *brush, INT *count)
1275 TRACE("(%p, %p)\n", brush, count);
1277 if (!brush || !count)
1278 return InvalidParameter;
1280 *count = brush->blendcount;
1282 return Ok;
1285 GpStatus WINGDIPAPI GdipSetLineGammaCorrection(GpLineGradient *line,
1286 BOOL usegamma)
1288 TRACE("(%p, %d)\n", line, usegamma);
1290 if(!line)
1291 return InvalidParameter;
1293 line->gamma = usegamma;
1295 return Ok;
1298 GpStatus WINGDIPAPI GdipSetLineSigmaBlend(GpLineGradient *line, REAL focus,
1299 REAL scale)
1301 REAL factors[33];
1302 REAL positions[33];
1303 int num_points = 0;
1304 int i;
1305 const int precision = 16;
1306 REAL erf_range; /* we use values erf(-erf_range) through erf(+erf_range) */
1307 REAL min_erf;
1308 REAL scale_erf;
1310 TRACE("(%p, %0.2f, %0.2f)\n", line, focus, scale);
1312 if(!line || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1313 return InvalidParameter;
1315 /* we want 2 standard deviations */
1316 erf_range = 2.0 / sqrt(2);
1318 /* calculate the constants we need to normalize the error function to be
1319 between 0.0 and scale over the range we need */
1320 min_erf = erf(-erf_range);
1321 scale_erf = scale / (-2.0 * min_erf);
1323 if (focus != 0.0)
1325 positions[0] = 0.0;
1326 factors[0] = 0.0;
1327 for (i=1; i<precision; i++)
1329 positions[i] = focus * i / precision;
1330 factors[i] = scale_erf * (erf(2 * erf_range * i / precision - erf_range) - min_erf);
1332 num_points += precision;
1335 positions[num_points] = focus;
1336 factors[num_points] = scale;
1337 num_points += 1;
1339 if (focus != 1.0)
1341 for (i=1; i<precision; i++)
1343 positions[i+num_points-1] = (focus + ((1.0-focus) * i / precision));
1344 factors[i+num_points-1] = scale_erf * (erf(erf_range - 2 * erf_range * i / precision) - min_erf);
1346 num_points += precision;
1347 positions[num_points-1] = 1.0;
1348 factors[num_points-1] = 0.0;
1351 return GdipSetLineBlend(line, factors, positions, num_points);
1354 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
1355 GpWrapMode wrap)
1357 TRACE("(%p, %d)\n", line, wrap);
1359 if(!line || wrap == WrapModeClamp)
1360 return InvalidParameter;
1362 line->wrap = wrap;
1364 return Ok;
1367 GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
1368 GDIPCONST REAL *pos, INT count)
1370 static int calls;
1372 TRACE("(%p,%p,%p,%i)\n", brush, blend, pos, count);
1374 if(!(calls++))
1375 FIXME("not implemented\n");
1377 return NotImplemented;
1380 GpStatus WINGDIPAPI GdipSetPathGradientLinearBlend(GpPathGradient *brush,
1381 REAL focus, REAL scale)
1383 static int calls;
1385 TRACE("(%p,%0.2f,%0.2f)\n", brush, focus, scale);
1387 if(!(calls++))
1388 FIXME("not implemented\n");
1390 return NotImplemented;
1393 GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
1394 GDIPCONST ARGB *blend, GDIPCONST REAL *pos, INT count)
1396 FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
1397 return NotImplemented;
1400 GpStatus WINGDIPAPI GdipGetPathGradientPresetBlend(GpPathGradient *brush,
1401 ARGB *blend, REAL *pos, INT count)
1403 FIXME("(%p,%p,%p,%i): stub\n", brush, blend, pos, count);
1404 return NotImplemented;
1407 GpStatus WINGDIPAPI GdipGetPathGradientPresetBlendCount(GpPathGradient *brush,
1408 INT *count)
1410 FIXME("(%p,%p): stub\n", brush, count);
1411 return NotImplemented;
1414 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
1415 ARGB argb)
1417 TRACE("(%p, %x)\n", grad, argb);
1419 if(!grad)
1420 return InvalidParameter;
1422 grad->centercolor = argb;
1423 return Ok;
1426 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
1427 GpPointF *point)
1429 TRACE("(%p, %s)\n", grad, debugstr_pointf(point));
1431 if(!grad || !point)
1432 return InvalidParameter;
1434 grad->center.X = point->X;
1435 grad->center.Y = point->Y;
1437 return Ok;
1440 GpStatus WINGDIPAPI GdipSetPathGradientCenterPointI(GpPathGradient *grad,
1441 GpPoint *point)
1443 GpPointF ptf;
1445 TRACE("(%p, %p)\n", grad, point);
1447 if(!point)
1448 return InvalidParameter;
1450 ptf.X = (REAL)point->X;
1451 ptf.Y = (REAL)point->Y;
1453 return GdipSetPathGradientCenterPoint(grad,&ptf);
1456 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
1457 REAL x, REAL y)
1459 TRACE("(%p, %.2f, %.2f)\n", grad, x, y);
1461 if(!grad)
1462 return InvalidParameter;
1464 grad->focus.X = x;
1465 grad->focus.Y = y;
1467 return Ok;
1470 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
1471 BOOL gamma)
1473 TRACE("(%p, %d)\n", grad, gamma);
1475 if(!grad)
1476 return InvalidParameter;
1478 grad->gamma = gamma;
1480 return Ok;
1483 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
1484 REAL focus, REAL scale)
1486 static int calls;
1488 TRACE("(%p,%0.2f,%0.2f)\n", grad, focus, scale);
1490 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
1491 return InvalidParameter;
1493 if(!(calls++))
1494 FIXME("not implemented\n");
1496 return NotImplemented;
1499 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1500 *grad, GDIPCONST ARGB *argb, INT *count)
1502 static int calls;
1504 TRACE("(%p,%p,%p)\n", grad, argb, count);
1506 if(!grad || !argb || !count || (*count <= 0) ||
1507 (*count > grad->path->pathdata.Count))
1508 return InvalidParameter;
1510 if(!(calls++))
1511 FIXME("not implemented\n");
1513 return NotImplemented;
1516 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
1517 GpWrapMode wrap)
1519 TRACE("(%p, %d)\n", grad, wrap);
1521 if(!grad)
1522 return InvalidParameter;
1524 grad->wrap = wrap;
1526 return Ok;
1529 GpStatus WINGDIPAPI GdipSetPathGradientTransform(GpPathGradient *grad,
1530 GpMatrix *matrix)
1532 static int calls;
1534 TRACE("(%p,%p)\n", grad, matrix);
1536 if(!(calls++))
1537 FIXME("not implemented\n");
1539 return NotImplemented;
1542 GpStatus WINGDIPAPI GdipGetPathGradientTransform(GpPathGradient *grad,
1543 GpMatrix *matrix)
1545 static int calls;
1547 TRACE("(%p,%p)\n", grad, matrix);
1549 if(!(calls++))
1550 FIXME("not implemented\n");
1552 return NotImplemented;
1555 GpStatus WINGDIPAPI GdipMultiplyPathGradientTransform(GpPathGradient *grad,
1556 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1558 static int calls;
1560 TRACE("(%p,%p,%i)\n", grad, matrix, order);
1562 if(!(calls++))
1563 FIXME("not implemented\n");
1565 return NotImplemented;
1568 GpStatus WINGDIPAPI GdipRotatePathGradientTransform(GpPathGradient *grad,
1569 REAL angle, GpMatrixOrder order)
1571 static int calls;
1573 TRACE("(%p,%0.2f,%i)\n", grad, angle, order);
1575 if(!(calls++))
1576 FIXME("not implemented\n");
1578 return NotImplemented;
1581 GpStatus WINGDIPAPI GdipScalePathGradientTransform(GpPathGradient *grad,
1582 REAL sx, REAL sy, GpMatrixOrder order)
1584 static int calls;
1586 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, sx, sy, order);
1588 if(!(calls++))
1589 FIXME("not implemented\n");
1591 return NotImplemented;
1594 GpStatus WINGDIPAPI GdipTranslatePathGradientTransform(GpPathGradient *grad,
1595 REAL dx, REAL dy, GpMatrixOrder order)
1597 static int calls;
1599 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad, dx, dy, order);
1601 if(!(calls++))
1602 FIXME("not implemented\n");
1604 return NotImplemented;
1607 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
1609 TRACE("(%p, %x)\n", sf, argb);
1611 if(!sf)
1612 return InvalidParameter;
1614 sf->color = argb;
1615 return Ok;
1618 /******************************************************************************
1619 * GdipSetTextureTransform [GDIPLUS.@]
1621 GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
1622 GDIPCONST GpMatrix *matrix)
1624 TRACE("(%p, %p)\n", texture, matrix);
1626 if(!texture || !matrix)
1627 return InvalidParameter;
1629 memcpy(texture->transform, matrix, sizeof(GpMatrix));
1631 return Ok;
1634 /******************************************************************************
1635 * GdipSetTextureWrapMode [GDIPLUS.@]
1637 * WrapMode not used, only stored
1639 GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
1641 TRACE("(%p, %d)\n", brush, wrapmode);
1643 if(!brush)
1644 return InvalidParameter;
1646 brush->imageattributes->wrap = wrapmode;
1648 return Ok;
1651 GpStatus WINGDIPAPI GdipSetLineColors(GpLineGradient *brush, ARGB color1,
1652 ARGB color2)
1654 TRACE("(%p, %x, %x)\n", brush, color1, color2);
1656 if(!brush)
1657 return InvalidParameter;
1659 brush->startcolor = color1;
1660 brush->endcolor = color2;
1662 return Ok;
1665 GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
1667 TRACE("(%p, %p)\n", brush, colors);
1669 if(!brush || !colors)
1670 return InvalidParameter;
1672 colors[0] = brush->startcolor;
1673 colors[1] = brush->endcolor;
1675 return Ok;
1678 /******************************************************************************
1679 * GdipRotateTextureTransform [GDIPLUS.@]
1681 GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
1682 GpMatrixOrder order)
1684 TRACE("(%p, %.2f, %d)\n", brush, angle, order);
1686 if(!brush)
1687 return InvalidParameter;
1689 return GdipRotateMatrix(brush->transform, angle, order);
1692 GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
1693 REAL scale)
1695 REAL factors[3];
1696 REAL positions[3];
1697 int num_points = 0;
1699 TRACE("(%p,%.2f,%.2f)\n", brush, focus, scale);
1701 if (!brush) return InvalidParameter;
1703 if (focus != 0.0)
1705 factors[num_points] = 0.0;
1706 positions[num_points] = 0.0;
1707 num_points++;
1710 factors[num_points] = scale;
1711 positions[num_points] = focus;
1712 num_points++;
1714 if (focus != 1.0)
1716 factors[num_points] = 0.0;
1717 positions[num_points] = 1.0;
1718 num_points++;
1721 return GdipSetLineBlend(brush, factors, positions, num_points);
1724 GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
1725 GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count)
1727 ARGB *new_color;
1728 REAL *new_pos;
1729 TRACE("(%p,%p,%p,%i)\n", brush, blend, positions, count);
1731 if (!brush || !blend || !positions || count < 2 ||
1732 positions[0] != 0.0f || positions[count-1] != 1.0f)
1734 return InvalidParameter;
1737 new_color = GdipAlloc(count * sizeof(ARGB));
1738 new_pos = GdipAlloc(count * sizeof(REAL));
1739 if (!new_color || !new_pos)
1741 GdipFree(new_color);
1742 GdipFree(new_pos);
1743 return OutOfMemory;
1746 memcpy(new_color, blend, sizeof(ARGB) * count);
1747 memcpy(new_pos, positions, sizeof(REAL) * count);
1749 GdipFree(brush->pblendcolor);
1750 GdipFree(brush->pblendpos);
1752 brush->pblendcolor = new_color;
1753 brush->pblendpos = new_pos;
1754 brush->pblendcount = count;
1756 return Ok;
1759 GpStatus WINGDIPAPI GdipGetLinePresetBlend(GpLineGradient *brush,
1760 ARGB *blend, REAL* positions, INT count)
1762 if (!brush || !blend || !positions || count < 2)
1763 return InvalidParameter;
1765 if (brush->pblendcount == 0)
1766 return GenericError;
1768 if (count < brush->pblendcount)
1769 return InsufficientBuffer;
1771 memcpy(blend, brush->pblendcolor, sizeof(ARGB) * brush->pblendcount);
1772 memcpy(positions, brush->pblendpos, sizeof(REAL) * brush->pblendcount);
1774 return Ok;
1777 GpStatus WINGDIPAPI GdipGetLinePresetBlendCount(GpLineGradient *brush,
1778 INT *count)
1780 if (!brush || !count)
1781 return InvalidParameter;
1783 *count = brush->pblendcount;
1785 return Ok;
1788 GpStatus WINGDIPAPI GdipResetLineTransform(GpLineGradient *brush)
1790 static int calls;
1792 TRACE("(%p)\n", brush);
1794 if(!(calls++))
1795 FIXME("not implemented\n");
1797 return NotImplemented;
1800 GpStatus WINGDIPAPI GdipSetLineTransform(GpLineGradient *brush,
1801 GDIPCONST GpMatrix *matrix)
1803 static int calls;
1805 TRACE("(%p,%p)\n", brush, matrix);
1807 if(!(calls++))
1808 FIXME("not implemented\n");
1810 return NotImplemented;
1813 GpStatus WINGDIPAPI GdipGetLineTransform(GpLineGradient *brush, GpMatrix *matrix)
1815 static int calls;
1817 TRACE("(%p,%p)\n", brush, matrix);
1819 if(!(calls++))
1820 FIXME("not implemented\n");
1822 return NotImplemented;
1825 GpStatus WINGDIPAPI GdipScaleLineTransform(GpLineGradient *brush, REAL sx, REAL sy,
1826 GpMatrixOrder order)
1828 static int calls;
1830 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush, sx, sy, order);
1832 if(!(calls++))
1833 FIXME("not implemented\n");
1835 return NotImplemented;
1838 GpStatus WINGDIPAPI GdipMultiplyLineTransform(GpLineGradient *brush,
1839 GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
1841 static int calls;
1843 TRACE("(%p,%p,%u)\n", brush, matrix, order);
1845 if(!(calls++))
1846 FIXME("not implemented\n");
1848 return NotImplemented;
1851 GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
1852 REAL dx, REAL dy, GpMatrixOrder order)
1854 static int calls;
1856 TRACE("(%p,%f,%f,%d)\n", brush, dx, dy, order);
1858 if(!(calls++))
1859 FIXME("not implemented\n");
1861 return Ok;
1864 /******************************************************************************
1865 * GdipTranslateTextureTransform [GDIPLUS.@]
1867 GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
1868 GpMatrixOrder order)
1870 TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);
1872 if(!brush)
1873 return InvalidParameter;
1875 return GdipTranslateMatrix(brush->transform, dx, dy, order);
1878 GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
1880 TRACE("(%p, %p)\n", brush, rect);
1882 if(!brush || !rect)
1883 return InvalidParameter;
1885 *rect = brush->rect;
1887 return Ok;
1890 GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
1892 GpRectF rectF;
1893 GpStatus ret;
1895 TRACE("(%p, %p)\n", brush, rect);
1897 if(!rect)
1898 return InvalidParameter;
1900 ret = GdipGetLineRect(brush, &rectF);
1902 if(ret == Ok){
1903 rect->X = roundr(rectF.X);
1904 rect->Y = roundr(rectF.Y);
1905 rect->Width = roundr(rectF.Width);
1906 rect->Height = roundr(rectF.Height);
1909 return ret;
1912 GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
1913 REAL angle, GpMatrixOrder order)
1915 static int calls;
1917 TRACE("(%p,%0.2f,%u)\n", brush, angle, order);
1919 if(!brush)
1920 return InvalidParameter;
1922 if(!(calls++))
1923 FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);
1925 return NotImplemented;