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
32 #include "gdiplus_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus
);
39 Code from http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/
43 const float a1
= 0.254829592;
44 const float a2
= -0.284496736;
45 const float a3
= 1.421413741;
46 const float a4
= -1.453152027;
47 const float a5
= 1.061405429;
48 const float p
= 0.3275911;
51 /* Save the sign of x */
59 y
= 1.0 - (((((a5
*t
+ a4
)*t
) + a3
)*t
+ a2
)*t
+ a1
)*t
*exp(-x
*x
);
64 /******************************************************************************
65 * GdipCloneBrush [GDIPLUS.@]
67 GpStatus WINGDIPAPI
GdipCloneBrush(GpBrush
*brush
, GpBrush
**clone
)
69 TRACE("(%p, %p)\n", brush
, clone
);
72 return InvalidParameter
;
75 case BrushTypeSolidColor
:
78 *clone
= GdipAlloc(sizeof(GpSolidFill
));
79 if (!*clone
) return OutOfMemory
;
81 fill
= (GpSolidFill
*)*clone
;
83 memcpy(*clone
, brush
, sizeof(GpSolidFill
));
85 (*clone
)->gdibrush
= CreateBrushIndirect(&(*clone
)->lb
);
86 fill
->bmp
= ARGB2BMP(fill
->color
);
89 case BrushTypeHatchFill
:
91 GpHatch
*hatch
= (GpHatch
*)brush
;
93 return GdipCreateHatchBrush(hatch
->hatchstyle
, hatch
->forecol
, hatch
->backcol
, (GpHatch
**)clone
);
95 case BrushTypePathGradient
:{
96 GpPathGradient
*src
, *dest
;
99 *clone
= GdipAlloc(sizeof(GpPathGradient
));
100 if (!*clone
) return OutOfMemory
;
102 src
= (GpPathGradient
*) brush
,
103 dest
= (GpPathGradient
*) *clone
;
104 count
= src
->pathdata
.Count
;
106 memcpy(dest
, src
, sizeof(GpPathGradient
));
108 dest
->pathdata
.Count
= count
;
109 dest
->pathdata
.Points
= GdipAlloc(count
* sizeof(PointF
));
110 dest
->pathdata
.Types
= GdipAlloc(count
);
112 if(!dest
->pathdata
.Points
|| !dest
->pathdata
.Types
){
113 GdipFree(dest
->pathdata
.Points
);
114 GdipFree(dest
->pathdata
.Types
);
119 memcpy(dest
->pathdata
.Points
, src
->pathdata
.Points
, count
* sizeof(PointF
));
120 memcpy(dest
->pathdata
.Types
, src
->pathdata
.Types
, count
);
123 count
= src
->blendcount
;
124 dest
->blendcount
= count
;
125 dest
->blendfac
= GdipAlloc(count
* sizeof(REAL
));
126 dest
->blendpos
= GdipAlloc(count
* sizeof(REAL
));
128 if(!dest
->blendfac
|| !dest
->blendpos
){
129 GdipFree(dest
->pathdata
.Points
);
130 GdipFree(dest
->pathdata
.Types
);
131 GdipFree(dest
->blendfac
);
132 GdipFree(dest
->blendpos
);
137 memcpy(dest
->blendfac
, src
->blendfac
, count
* sizeof(REAL
));
138 memcpy(dest
->blendpos
, src
->blendpos
, count
* sizeof(REAL
));
142 case BrushTypeLinearGradient
:{
143 GpLineGradient
*dest
, *src
;
146 dest
= GdipAlloc(sizeof(GpLineGradient
));
147 if(!dest
) return OutOfMemory
;
149 src
= (GpLineGradient
*)brush
;
151 memcpy(dest
, src
, sizeof(GpLineGradient
));
153 dest
->brush
.gdibrush
= CreateSolidBrush(dest
->brush
.lb
.lbColor
);
155 count
= dest
->blendcount
;
156 dest
->blendfac
= GdipAlloc(count
* sizeof(REAL
));
157 dest
->blendpos
= GdipAlloc(count
* sizeof(REAL
));
158 pcount
= dest
->pblendcount
;
161 dest
->pblendcolor
= GdipAlloc(pcount
* sizeof(ARGB
));
162 dest
->pblendpos
= GdipAlloc(pcount
* sizeof(REAL
));
165 if (!dest
->blendfac
|| !dest
->blendpos
||
166 (pcount
&& (!dest
->pblendcolor
|| !dest
->pblendpos
)))
168 GdipFree(dest
->blendfac
);
169 GdipFree(dest
->blendpos
);
170 GdipFree(dest
->pblendcolor
);
171 GdipFree(dest
->pblendpos
);
172 DeleteObject(dest
->brush
.gdibrush
);
177 memcpy(dest
->blendfac
, src
->blendfac
, count
* sizeof(REAL
));
178 memcpy(dest
->blendpos
, src
->blendpos
, count
* sizeof(REAL
));
182 memcpy(dest
->pblendcolor
, src
->pblendcolor
, pcount
* sizeof(ARGB
));
183 memcpy(dest
->pblendpos
, src
->pblendpos
, pcount
* sizeof(REAL
));
186 *clone
= &dest
->brush
;
189 case BrushTypeTextureFill
:
192 GpTexture
*texture
= (GpTexture
*)brush
;
193 GpTexture
*new_texture
;
195 stat
= GdipCreateTexture(texture
->image
, texture
->wrap
, &new_texture
);
199 memcpy(new_texture
->transform
, texture
->transform
, sizeof(GpMatrix
));
200 *clone
= (GpBrush
*)new_texture
;
208 ERR("not implemented for brush type %d\n", brush
->bt
);
209 return NotImplemented
;
212 TRACE("<-- %p\n", *clone
);
216 static const char HatchBrushes
[][8] = {
217 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
218 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
219 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
220 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
221 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
222 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
223 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
224 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
225 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
226 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
227 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
228 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
229 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
230 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
231 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
232 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
233 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
234 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
235 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
236 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
237 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
238 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
239 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
240 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
241 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
242 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
243 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
244 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
245 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
246 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
249 /******************************************************************************
250 * GdipCreateHatchBrush [GDIPLUS.@]
252 GpStatus WINGDIPAPI
GdipCreateHatchBrush(HatchStyle hatchstyle
, ARGB forecol
, ARGB backcol
, GpHatch
**brush
)
254 COLORREF fgcol
= ARGB2COLORREF(forecol
);
257 TRACE("(%d, %d, %d, %p)\n", hatchstyle
, forecol
, backcol
, brush
);
259 if(!brush
) return InvalidParameter
;
261 *brush
= GdipAlloc(sizeof(GpHatch
));
262 if (!*brush
) return OutOfMemory
;
264 if (hatchstyle
< sizeof(HatchBrushes
) / sizeof(HatchBrushes
[0]))
268 BITMAPINFOHEADER bmih
;
272 hdc
= CreateCompatibleDC(0);
276 bmih
.biSize
= sizeof(bmih
);
280 bmih
.biBitCount
= 32;
281 bmih
.biCompression
= BI_RGB
;
282 bmih
.biSizeImage
= 0;
284 hbmp
= CreateDIBSection(hdc
, (BITMAPINFO
*)&bmih
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
290 if ((HatchBrushes
[hatchstyle
][y
] & (0x80 >> x
)) != 0)
291 bits
[y
*8+x
] = forecol
;
293 bits
[y
*8+x
] = backcol
;
305 (*brush
)->brush
.lb
.lbStyle
= BS_PATTERN
;
306 (*brush
)->brush
.lb
.lbColor
= 0;
307 (*brush
)->brush
.lb
.lbHatch
= (ULONG_PTR
)hbmp
;
308 (*brush
)->brush
.gdibrush
= CreateBrushIndirect(&(*brush
)->brush
.lb
);
315 FIXME("Unimplemented hatch style %d\n", hatchstyle
);
317 (*brush
)->brush
.lb
.lbStyle
= BS_SOLID
;
318 (*brush
)->brush
.lb
.lbColor
= fgcol
;
319 (*brush
)->brush
.lb
.lbHatch
= 0;
320 (*brush
)->brush
.gdibrush
= CreateBrushIndirect(&(*brush
)->brush
.lb
);
325 (*brush
)->brush
.bt
= BrushTypeHatchFill
;
326 (*brush
)->forecol
= forecol
;
327 (*brush
)->backcol
= backcol
;
328 (*brush
)->hatchstyle
= hatchstyle
;
329 TRACE("<-- %p\n", *brush
);
340 /******************************************************************************
341 * GdipCreateLineBrush [GDIPLUS.@]
343 GpStatus WINGDIPAPI
GdipCreateLineBrush(GDIPCONST GpPointF
* startpoint
,
344 GDIPCONST GpPointF
* endpoint
, ARGB startcolor
, ARGB endcolor
,
345 GpWrapMode wrap
, GpLineGradient
**line
)
347 COLORREF col
= ARGB2COLORREF(startcolor
);
349 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint
),
350 debugstr_pointf(endpoint
), startcolor
, endcolor
, wrap
, line
);
352 if(!line
|| !startpoint
|| !endpoint
|| wrap
== WrapModeClamp
)
353 return InvalidParameter
;
355 *line
= GdipAlloc(sizeof(GpLineGradient
));
356 if(!*line
) return OutOfMemory
;
358 (*line
)->brush
.lb
.lbStyle
= BS_SOLID
;
359 (*line
)->brush
.lb
.lbColor
= col
;
360 (*line
)->brush
.lb
.lbHatch
= 0;
361 (*line
)->brush
.gdibrush
= CreateSolidBrush(col
);
362 (*line
)->brush
.bt
= BrushTypeLinearGradient
;
364 (*line
)->startpoint
.X
= startpoint
->X
;
365 (*line
)->startpoint
.Y
= startpoint
->Y
;
366 (*line
)->endpoint
.X
= endpoint
->X
;
367 (*line
)->endpoint
.Y
= endpoint
->Y
;
368 (*line
)->startcolor
= startcolor
;
369 (*line
)->endcolor
= endcolor
;
370 (*line
)->wrap
= wrap
;
371 (*line
)->gamma
= FALSE
;
373 (*line
)->rect
.X
= (startpoint
->X
< endpoint
->X
? startpoint
->X
: endpoint
->X
);
374 (*line
)->rect
.Y
= (startpoint
->Y
< endpoint
->Y
? startpoint
->Y
: endpoint
->Y
);
375 (*line
)->rect
.Width
= fabs(startpoint
->X
- endpoint
->X
);
376 (*line
)->rect
.Height
= fabs(startpoint
->Y
- endpoint
->Y
);
378 if ((*line
)->rect
.Width
== 0)
380 (*line
)->rect
.X
-= (*line
)->rect
.Height
/ 2.0f
;
381 (*line
)->rect
.Width
= (*line
)->rect
.Height
;
383 else if ((*line
)->rect
.Height
== 0)
385 (*line
)->rect
.Y
-= (*line
)->rect
.Width
/ 2.0f
;
386 (*line
)->rect
.Height
= (*line
)->rect
.Width
;
389 (*line
)->blendcount
= 1;
390 (*line
)->blendfac
= GdipAlloc(sizeof(REAL
));
391 (*line
)->blendpos
= GdipAlloc(sizeof(REAL
));
393 if (!(*line
)->blendfac
|| !(*line
)->blendpos
)
395 GdipFree((*line
)->blendfac
);
396 GdipFree((*line
)->blendpos
);
397 DeleteObject((*line
)->brush
.gdibrush
);
403 (*line
)->blendfac
[0] = 1.0f
;
404 (*line
)->blendpos
[0] = 1.0f
;
406 (*line
)->pblendcolor
= NULL
;
407 (*line
)->pblendpos
= NULL
;
408 (*line
)->pblendcount
= 0;
410 TRACE("<-- %p\n", *line
);
415 GpStatus WINGDIPAPI
GdipCreateLineBrushI(GDIPCONST GpPoint
* startpoint
,
416 GDIPCONST GpPoint
* endpoint
, ARGB startcolor
, ARGB endcolor
,
417 GpWrapMode wrap
, GpLineGradient
**line
)
422 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint
, endpoint
,
423 startcolor
, endcolor
, wrap
, line
);
425 if(!startpoint
|| !endpoint
)
426 return InvalidParameter
;
428 stF
.X
= (REAL
)startpoint
->X
;
429 stF
.Y
= (REAL
)startpoint
->Y
;
430 endF
.X
= (REAL
)endpoint
->X
;
431 endF
.X
= (REAL
)endpoint
->Y
;
433 return GdipCreateLineBrush(&stF
, &endF
, startcolor
, endcolor
, wrap
, line
);
436 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRect(GDIPCONST GpRectF
* rect
,
437 ARGB startcolor
, ARGB endcolor
, LinearGradientMode mode
, GpWrapMode wrap
,
438 GpLineGradient
**line
)
443 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect
, startcolor
, endcolor
, mode
,
447 return InvalidParameter
;
451 case LinearGradientModeHorizontal
:
454 end
.X
= rect
->X
+ rect
->Width
;
457 case LinearGradientModeVertical
:
461 end
.Y
= rect
->Y
+ rect
->Height
;
463 case LinearGradientModeForwardDiagonal
:
466 end
.X
= rect
->X
+ rect
->Width
;
467 end
.Y
= rect
->Y
+ rect
->Height
;
469 case LinearGradientModeBackwardDiagonal
:
470 start
.X
= rect
->X
+ rect
->Width
;
473 end
.Y
= rect
->Y
+ rect
->Height
;
476 return InvalidParameter
;
479 stat
= GdipCreateLineBrush(&start
, &end
, startcolor
, endcolor
, wrap
, line
);
482 (*line
)->rect
= *rect
;
487 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectI(GDIPCONST GpRect
* rect
,
488 ARGB startcolor
, ARGB endcolor
, LinearGradientMode mode
, GpWrapMode wrap
,
489 GpLineGradient
**line
)
493 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect
, startcolor
, endcolor
, mode
,
496 rectF
.X
= (REAL
) rect
->X
;
497 rectF
.Y
= (REAL
) rect
->Y
;
498 rectF
.Width
= (REAL
) rect
->Width
;
499 rectF
.Height
= (REAL
) rect
->Height
;
501 return GdipCreateLineBrushFromRect(&rectF
, startcolor
, endcolor
, mode
, wrap
, line
);
504 /******************************************************************************
505 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
507 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF
* rect
,
508 ARGB startcolor
, ARGB endcolor
, REAL angle
, BOOL isAngleScalable
, GpWrapMode wrap
,
509 GpLineGradient
**line
)
512 LinearGradientMode mode
;
513 REAL width
, height
, exofs
, eyofs
;
514 REAL sin_angle
, cos_angle
, sin_cos_angle
;
516 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect
, startcolor
, endcolor
, angle
, isAngleScalable
,
519 sin_angle
= sinf(deg2rad(angle
));
520 cos_angle
= cosf(deg2rad(angle
));
521 sin_cos_angle
= sin_angle
* cos_angle
;
525 width
= height
= 1.0;
530 height
= rect
->Height
;
533 if (sin_cos_angle
>= 0)
534 mode
= LinearGradientModeForwardDiagonal
;
536 mode
= LinearGradientModeBackwardDiagonal
;
538 stat
= GdipCreateLineBrushFromRect(rect
, startcolor
, endcolor
, mode
, wrap
, line
);
542 if (sin_cos_angle
>= 0)
544 exofs
= width
* sin_cos_angle
+ height
* cos_angle
* cos_angle
;
545 eyofs
= width
* sin_angle
* sin_angle
+ height
* sin_cos_angle
;
549 exofs
= width
* sin_angle
* sin_angle
+ height
* sin_cos_angle
;
550 eyofs
= -width
* sin_cos_angle
+ height
* sin_angle
* sin_angle
;
555 exofs
= exofs
* rect
->Width
;
556 eyofs
= eyofs
* rect
->Height
;
561 (*line
)->endpoint
.X
= rect
->X
+ exofs
;
562 (*line
)->endpoint
.Y
= rect
->Y
+ eyofs
;
566 (*line
)->endpoint
.X
= (*line
)->startpoint
.X
;
567 (*line
)->endpoint
.Y
= (*line
)->startpoint
.Y
;
568 (*line
)->startpoint
.X
= rect
->X
+ exofs
;
569 (*line
)->startpoint
.Y
= rect
->Y
+ eyofs
;
576 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect
* rect
,
577 ARGB startcolor
, ARGB endcolor
, REAL angle
, BOOL isAngleScalable
, GpWrapMode wrap
,
578 GpLineGradient
**line
)
580 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect
, startcolor
, endcolor
, angle
, isAngleScalable
,
583 return GdipCreateLineBrushFromRectI(rect
, startcolor
, endcolor
, LinearGradientModeForwardDiagonal
,
587 GpStatus WINGDIPAPI
GdipCreatePathGradient(GDIPCONST GpPointF
* points
,
588 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
590 COLORREF col
= ARGB2COLORREF(0xffffffff);
592 TRACE("(%p, %d, %d, %p)\n", points
, count
, wrap
, grad
);
595 return InvalidParameter
;
600 *grad
= GdipAlloc(sizeof(GpPathGradient
));
601 if (!*grad
) return OutOfMemory
;
603 (*grad
)->blendfac
= GdipAlloc(sizeof(REAL
));
604 if(!(*grad
)->blendfac
){
608 (*grad
)->blendfac
[0] = 1.0;
609 (*grad
)->blendpos
= NULL
;
610 (*grad
)->blendcount
= 1;
612 (*grad
)->pathdata
.Count
= count
;
613 (*grad
)->pathdata
.Points
= GdipAlloc(count
* sizeof(PointF
));
614 (*grad
)->pathdata
.Types
= GdipAlloc(count
);
616 if(!(*grad
)->pathdata
.Points
|| !(*grad
)->pathdata
.Types
){
617 GdipFree((*grad
)->pathdata
.Points
);
618 GdipFree((*grad
)->pathdata
.Types
);
623 memcpy((*grad
)->pathdata
.Points
, points
, count
* sizeof(PointF
));
624 memset((*grad
)->pathdata
.Types
, PathPointTypeLine
, count
);
626 (*grad
)->brush
.lb
.lbStyle
= BS_SOLID
;
627 (*grad
)->brush
.lb
.lbColor
= col
;
628 (*grad
)->brush
.lb
.lbHatch
= 0;
630 (*grad
)->brush
.gdibrush
= CreateSolidBrush(col
);
631 (*grad
)->brush
.bt
= BrushTypePathGradient
;
632 (*grad
)->centercolor
= 0xffffffff;
633 (*grad
)->wrap
= wrap
;
634 (*grad
)->gamma
= FALSE
;
635 (*grad
)->center
.X
= 0.0;
636 (*grad
)->center
.Y
= 0.0;
637 (*grad
)->focus
.X
= 0.0;
638 (*grad
)->focus
.Y
= 0.0;
640 TRACE("<-- %p\n", *grad
);
645 GpStatus WINGDIPAPI
GdipCreatePathGradientI(GDIPCONST GpPoint
* points
,
646 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
652 TRACE("(%p, %d, %d, %p)\n", points
, count
, wrap
, grad
);
655 return InvalidParameter
;
660 pointsF
= GdipAlloc(sizeof(GpPointF
) * count
);
664 for(i
= 0; i
< count
; i
++){
665 pointsF
[i
].X
= (REAL
)points
[i
].X
;
666 pointsF
[i
].Y
= (REAL
)points
[i
].Y
;
669 ret
= GdipCreatePathGradient(pointsF
, count
, wrap
, grad
);
675 /******************************************************************************
676 * GdipCreatePathGradientFromPath [GDIPLUS.@]
678 * FIXME: path gradient brushes not truly supported (drawn as solid brushes)
680 GpStatus WINGDIPAPI
GdipCreatePathGradientFromPath(GDIPCONST GpPath
* path
,
681 GpPathGradient
**grad
)
683 COLORREF col
= ARGB2COLORREF(0xffffffff);
685 TRACE("(%p, %p)\n", path
, grad
);
688 return InvalidParameter
;
690 *grad
= GdipAlloc(sizeof(GpPathGradient
));
691 if (!*grad
) return OutOfMemory
;
693 (*grad
)->blendfac
= GdipAlloc(sizeof(REAL
));
694 if(!(*grad
)->blendfac
){
698 (*grad
)->blendfac
[0] = 1.0;
699 (*grad
)->blendpos
= NULL
;
700 (*grad
)->blendcount
= 1;
702 (*grad
)->pathdata
.Count
= path
->pathdata
.Count
;
703 (*grad
)->pathdata
.Points
= GdipAlloc(path
->pathdata
.Count
* sizeof(PointF
));
704 (*grad
)->pathdata
.Types
= GdipAlloc(path
->pathdata
.Count
);
706 if(!(*grad
)->pathdata
.Points
|| !(*grad
)->pathdata
.Types
){
707 GdipFree((*grad
)->pathdata
.Points
);
708 GdipFree((*grad
)->pathdata
.Types
);
713 memcpy((*grad
)->pathdata
.Points
, path
->pathdata
.Points
,
714 path
->pathdata
.Count
* sizeof(PointF
));
715 memcpy((*grad
)->pathdata
.Types
, path
->pathdata
.Types
, path
->pathdata
.Count
);
717 (*grad
)->brush
.lb
.lbStyle
= BS_SOLID
;
718 (*grad
)->brush
.lb
.lbColor
= col
;
719 (*grad
)->brush
.lb
.lbHatch
= 0;
721 (*grad
)->brush
.gdibrush
= CreateSolidBrush(col
);
722 (*grad
)->brush
.bt
= BrushTypePathGradient
;
723 (*grad
)->centercolor
= 0xffffffff;
724 (*grad
)->wrap
= WrapModeClamp
;
725 (*grad
)->gamma
= FALSE
;
726 /* FIXME: this should be set to the "centroid" of the path by default */
727 (*grad
)->center
.X
= 0.0;
728 (*grad
)->center
.Y
= 0.0;
729 (*grad
)->focus
.X
= 0.0;
730 (*grad
)->focus
.Y
= 0.0;
732 TRACE("<-- %p\n", *grad
);
737 /******************************************************************************
738 * GdipCreateSolidFill [GDIPLUS.@]
740 GpStatus WINGDIPAPI
GdipCreateSolidFill(ARGB color
, GpSolidFill
**sf
)
742 COLORREF col
= ARGB2COLORREF(color
);
744 TRACE("(%x, %p)\n", color
, sf
);
746 if(!sf
) return InvalidParameter
;
748 *sf
= GdipAlloc(sizeof(GpSolidFill
));
749 if (!*sf
) return OutOfMemory
;
751 (*sf
)->brush
.lb
.lbStyle
= BS_SOLID
;
752 (*sf
)->brush
.lb
.lbColor
= col
;
753 (*sf
)->brush
.lb
.lbHatch
= 0;
755 (*sf
)->brush
.gdibrush
= CreateSolidBrush(col
);
756 (*sf
)->brush
.bt
= BrushTypeSolidColor
;
757 (*sf
)->color
= color
;
758 (*sf
)->bmp
= ARGB2BMP(color
);
760 TRACE("<-- %p\n", *sf
);
765 /******************************************************************************
766 * GdipCreateTexture [GDIPLUS.@]
769 * image [I] image to use
770 * wrapmode [I] optional
771 * texture [O] pointer to the resulting texturebrush
775 * FAILURE: element of GpStatus
777 GpStatus WINGDIPAPI
GdipCreateTexture(GpImage
*image
, GpWrapMode wrapmode
,
781 GpImageAttributes attributes
;
784 TRACE("%p, %d %p\n", image
, wrapmode
, texture
);
786 if (!(image
&& texture
))
787 return InvalidParameter
;
789 stat
= GdipGetImageWidth(image
, &width
);
790 if (stat
!= Ok
) return stat
;
791 stat
= GdipGetImageHeight(image
, &height
);
792 if (stat
!= Ok
) return stat
;
793 attributes
.wrap
= wrapmode
;
795 return GdipCreateTextureIA(image
, &attributes
, 0, 0, width
, height
,
799 /******************************************************************************
800 * GdipCreateTexture2 [GDIPLUS.@]
802 GpStatus WINGDIPAPI
GdipCreateTexture2(GpImage
*image
, GpWrapMode wrapmode
,
803 REAL x
, REAL y
, REAL width
, REAL height
, GpTexture
**texture
)
805 GpImageAttributes attributes
;
807 TRACE("%p %d %f %f %f %f %p\n", image
, wrapmode
,
808 x
, y
, width
, height
, texture
);
810 attributes
.wrap
= wrapmode
;
811 return GdipCreateTextureIA(image
, &attributes
, x
, y
, width
, height
,
815 /******************************************************************************
816 * GdipCreateTextureIA [GDIPLUS.@]
818 * FIXME: imageattr ignored
820 GpStatus WINGDIPAPI
GdipCreateTextureIA(GpImage
*image
,
821 GDIPCONST GpImageAttributes
*imageattr
, REAL x
, REAL y
, REAL width
,
822 REAL height
, GpTexture
**texture
)
826 GpImage
*new_image
=NULL
;
828 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image
, imageattr
, x
, y
, width
, height
,
831 if(!image
|| !texture
|| x
< 0.0 || y
< 0.0 || width
< 0.0 || height
< 0.0)
832 return InvalidParameter
;
836 if(image
->type
!= ImageTypeBitmap
){
837 FIXME("not implemented for image type %d\n", image
->type
);
838 return NotImplemented
;
841 status
= GdipCloneBitmapArea(x
, y
, width
, height
, PixelFormatDontCare
, (GpBitmap
*)image
, (GpBitmap
**)&new_image
);
845 hbm
= ((GpBitmap
*)new_image
)->hbitmap
;
848 status
= GenericError
;
852 *texture
= GdipAlloc(sizeof(GpTexture
));
854 status
= OutOfMemory
;
858 if((status
= GdipCreateMatrix(&(*texture
)->transform
)) != Ok
){
862 (*texture
)->brush
.lb
.lbStyle
= BS_PATTERN
;
863 (*texture
)->brush
.lb
.lbColor
= 0;
864 (*texture
)->brush
.lb
.lbHatch
= (ULONG_PTR
)hbm
;
866 (*texture
)->brush
.gdibrush
= CreateBrushIndirect(&(*texture
)->brush
.lb
);
867 (*texture
)->brush
.bt
= BrushTypeTextureFill
;
869 (*texture
)->wrap
= imageattr
->wrap
;
871 (*texture
)->wrap
= WrapModeTile
;
872 (*texture
)->image
= new_image
;
877 TRACE("<-- %p\n", *texture
);
883 GdipDeleteMatrix((*texture
)->transform
);
887 GdipDisposeImage(new_image
);
888 TRACE("<-- error %u\n", status
);
894 /******************************************************************************
895 * GdipCreateTextureIAI [GDIPLUS.@]
897 GpStatus WINGDIPAPI
GdipCreateTextureIAI(GpImage
*image
, GDIPCONST GpImageAttributes
*imageattr
,
898 INT x
, INT y
, INT width
, INT height
, GpTexture
**texture
)
900 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image
, imageattr
, x
, y
, width
, height
,
903 return GdipCreateTextureIA(image
,imageattr
,(REAL
)x
,(REAL
)y
,(REAL
)width
,(REAL
)height
,texture
);
906 GpStatus WINGDIPAPI
GdipCreateTexture2I(GpImage
*image
, GpWrapMode wrapmode
,
907 INT x
, INT y
, INT width
, INT height
, GpTexture
**texture
)
909 GpImageAttributes imageattr
;
911 TRACE("%p %d %d %d %d %d %p\n", image
, wrapmode
, x
, y
, width
, height
,
914 imageattr
.wrap
= wrapmode
;
916 return GdipCreateTextureIA(image
, &imageattr
, x
, y
, width
, height
, texture
);
919 GpStatus WINGDIPAPI
GdipGetBrushType(GpBrush
*brush
, GpBrushType
*type
)
921 TRACE("(%p, %p)\n", brush
, type
);
923 if(!brush
|| !type
) return InvalidParameter
;
930 GpStatus WINGDIPAPI
GdipGetHatchBackgroundColor(GpHatch
*brush
, ARGB
*backcol
)
932 TRACE("(%p, %p)\n", brush
, backcol
);
934 if(!brush
|| !backcol
) return InvalidParameter
;
936 *backcol
= brush
->backcol
;
941 GpStatus WINGDIPAPI
GdipGetHatchForegroundColor(GpHatch
*brush
, ARGB
*forecol
)
943 TRACE("(%p, %p)\n", brush
, forecol
);
945 if(!brush
|| !forecol
) return InvalidParameter
;
947 *forecol
= brush
->forecol
;
952 GpStatus WINGDIPAPI
GdipGetHatchStyle(GpHatch
*brush
, HatchStyle
*hatchstyle
)
954 TRACE("(%p, %p)\n", brush
, hatchstyle
);
956 if(!brush
|| !hatchstyle
) return InvalidParameter
;
958 *hatchstyle
= brush
->hatchstyle
;
963 GpStatus WINGDIPAPI
GdipDeleteBrush(GpBrush
*brush
)
965 TRACE("(%p)\n", brush
);
967 if(!brush
) return InvalidParameter
;
971 case BrushTypePathGradient
:
972 GdipFree(((GpPathGradient
*) brush
)->pathdata
.Points
);
973 GdipFree(((GpPathGradient
*) brush
)->pathdata
.Types
);
974 GdipFree(((GpPathGradient
*) brush
)->blendfac
);
975 GdipFree(((GpPathGradient
*) brush
)->blendpos
);
977 case BrushTypeSolidColor
:
978 if (((GpSolidFill
*)brush
)->bmp
)
979 DeleteObject(((GpSolidFill
*)brush
)->bmp
);
981 case BrushTypeLinearGradient
:
982 GdipFree(((GpLineGradient
*)brush
)->blendfac
);
983 GdipFree(((GpLineGradient
*)brush
)->blendpos
);
984 GdipFree(((GpLineGradient
*)brush
)->pblendcolor
);
985 GdipFree(((GpLineGradient
*)brush
)->pblendpos
);
987 case BrushTypeTextureFill
:
988 GdipDeleteMatrix(((GpTexture
*)brush
)->transform
);
989 GdipDisposeImage(((GpTexture
*)brush
)->image
);
995 DeleteObject(brush
->gdibrush
);
1001 GpStatus WINGDIPAPI
GdipGetLineGammaCorrection(GpLineGradient
*line
,
1004 TRACE("(%p, %p)\n", line
, usinggamma
);
1006 if(!line
|| !usinggamma
)
1007 return InvalidParameter
;
1009 *usinggamma
= line
->gamma
;
1014 GpStatus WINGDIPAPI
GdipGetLineWrapMode(GpLineGradient
*brush
, GpWrapMode
*wrapmode
)
1016 TRACE("(%p, %p)\n", brush
, wrapmode
);
1018 if(!brush
|| !wrapmode
)
1019 return InvalidParameter
;
1021 *wrapmode
= brush
->wrap
;
1026 GpStatus WINGDIPAPI
GdipGetPathGradientBlend(GpPathGradient
*brush
, REAL
*blend
,
1027 REAL
*positions
, INT count
)
1029 TRACE("(%p, %p, %p, %d)\n", brush
, blend
, positions
, count
);
1031 if(!brush
|| !blend
|| !positions
|| count
<= 0)
1032 return InvalidParameter
;
1034 if(count
< brush
->blendcount
)
1035 return InsufficientBuffer
;
1037 memcpy(blend
, brush
->blendfac
, count
*sizeof(REAL
));
1038 if(brush
->blendcount
> 1){
1039 memcpy(positions
, brush
->blendpos
, count
*sizeof(REAL
));
1045 GpStatus WINGDIPAPI
GdipGetPathGradientBlendCount(GpPathGradient
*brush
, INT
*count
)
1047 TRACE("(%p, %p)\n", brush
, count
);
1049 if(!brush
|| !count
)
1050 return InvalidParameter
;
1052 *count
= brush
->blendcount
;
1057 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPoint(GpPathGradient
*grad
,
1060 TRACE("(%p, %p)\n", grad
, point
);
1063 return InvalidParameter
;
1065 point
->X
= grad
->center
.X
;
1066 point
->Y
= grad
->center
.Y
;
1071 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPointI(GpPathGradient
*grad
,
1077 TRACE("(%p, %p)\n", grad
, point
);
1080 return InvalidParameter
;
1082 ret
= GdipGetPathGradientCenterPoint(grad
,&ptf
);
1085 point
->X
= roundr(ptf
.X
);
1086 point
->Y
= roundr(ptf
.Y
);
1092 GpStatus WINGDIPAPI
GdipGetPathGradientFocusScales(GpPathGradient
*grad
,
1095 TRACE("(%p, %p, %p)\n", grad
, x
, y
);
1097 if(!grad
|| !x
|| !y
)
1098 return InvalidParameter
;
1106 GpStatus WINGDIPAPI
GdipGetPathGradientGammaCorrection(GpPathGradient
*grad
,
1109 TRACE("(%p, %p)\n", grad
, gamma
);
1112 return InvalidParameter
;
1114 *gamma
= grad
->gamma
;
1119 GpStatus WINGDIPAPI
GdipGetPathGradientPointCount(GpPathGradient
*grad
,
1122 TRACE("(%p, %p)\n", grad
, count
);
1125 return InvalidParameter
;
1127 *count
= grad
->pathdata
.Count
;
1132 GpStatus WINGDIPAPI
GdipGetPathGradientRect(GpPathGradient
*brush
, GpRectF
*rect
)
1138 TRACE("(%p, %p)\n", brush
, rect
);
1141 return InvalidParameter
;
1143 stat
= GdipCreatePath2(brush
->pathdata
.Points
, brush
->pathdata
.Types
,
1144 brush
->pathdata
.Count
, FillModeAlternate
, &path
);
1145 if(stat
!= Ok
) return stat
;
1147 stat
= GdipGetPathWorldBounds(path
, &r
, NULL
, NULL
);
1149 GdipDeletePath(path
);
1153 memcpy(rect
, &r
, sizeof(GpRectF
));
1155 GdipDeletePath(path
);
1160 GpStatus WINGDIPAPI
GdipGetPathGradientRectI(GpPathGradient
*brush
, GpRect
*rect
)
1165 TRACE("(%p, %p)\n", brush
, rect
);
1168 return InvalidParameter
;
1170 stat
= GdipGetPathGradientRect(brush
, &rectf
);
1171 if(stat
!= Ok
) return stat
;
1173 rect
->X
= roundr(rectf
.X
);
1174 rect
->Y
= roundr(rectf
.Y
);
1175 rect
->Width
= roundr(rectf
.Width
);
1176 rect
->Height
= roundr(rectf
.Height
);
1181 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1182 *grad
, ARGB
*argb
, INT
*count
)
1186 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1188 if(!grad
|| !argb
|| !count
|| (*count
< grad
->pathdata
.Count
))
1189 return InvalidParameter
;
1192 FIXME("not implemented\n");
1194 return NotImplemented
;
1197 GpStatus WINGDIPAPI
GdipGetPathGradientWrapMode(GpPathGradient
*brush
,
1198 GpWrapMode
*wrapmode
)
1200 TRACE("(%p, %p)\n", brush
, wrapmode
);
1202 if(!brush
|| !wrapmode
)
1203 return InvalidParameter
;
1205 *wrapmode
= brush
->wrap
;
1210 GpStatus WINGDIPAPI
GdipGetSolidFillColor(GpSolidFill
*sf
, ARGB
*argb
)
1212 TRACE("(%p, %p)\n", sf
, argb
);
1215 return InvalidParameter
;
1222 /******************************************************************************
1223 * GdipGetTextureImage [GDIPLUS.@]
1225 GpStatus WINGDIPAPI
GdipGetTextureImage(GpTexture
*brush
, GpImage
**image
)
1227 TRACE("(%p, %p)\n", brush
, image
);
1229 if(!brush
|| !image
)
1230 return InvalidParameter
;
1232 return GdipCloneImage(brush
->image
, image
);
1235 /******************************************************************************
1236 * GdipGetTextureTransform [GDIPLUS.@]
1238 GpStatus WINGDIPAPI
GdipGetTextureTransform(GpTexture
*brush
, GpMatrix
*matrix
)
1240 TRACE("(%p, %p)\n", brush
, matrix
);
1242 if(!brush
|| !matrix
)
1243 return InvalidParameter
;
1245 memcpy(matrix
, brush
->transform
, sizeof(GpMatrix
));
1250 /******************************************************************************
1251 * GdipGetTextureWrapMode [GDIPLUS.@]
1253 GpStatus WINGDIPAPI
GdipGetTextureWrapMode(GpTexture
*brush
, GpWrapMode
*wrapmode
)
1255 TRACE("(%p, %p)\n", brush
, wrapmode
);
1257 if(!brush
|| !wrapmode
)
1258 return InvalidParameter
;
1260 *wrapmode
= brush
->wrap
;
1265 /******************************************************************************
1266 * GdipMultiplyTextureTransform [GDIPLUS.@]
1268 GpStatus WINGDIPAPI
GdipMultiplyTextureTransform(GpTexture
* brush
,
1269 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1271 TRACE("(%p, %p, %d)\n", brush
, matrix
, order
);
1273 if(!brush
|| !matrix
)
1274 return InvalidParameter
;
1276 return GdipMultiplyMatrix(brush
->transform
, matrix
, order
);
1279 /******************************************************************************
1280 * GdipResetTextureTransform [GDIPLUS.@]
1282 GpStatus WINGDIPAPI
GdipResetTextureTransform(GpTexture
* brush
)
1284 TRACE("(%p)\n", brush
);
1287 return InvalidParameter
;
1289 return GdipSetMatrixElements(brush
->transform
, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1292 /******************************************************************************
1293 * GdipScaleTextureTransform [GDIPLUS.@]
1295 GpStatus WINGDIPAPI
GdipScaleTextureTransform(GpTexture
* brush
,
1296 REAL sx
, REAL sy
, GpMatrixOrder order
)
1298 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, sx
, sy
, order
);
1301 return InvalidParameter
;
1303 return GdipScaleMatrix(brush
->transform
, sx
, sy
, order
);
1306 GpStatus WINGDIPAPI
GdipSetLineBlend(GpLineGradient
*brush
,
1307 GDIPCONST REAL
*factors
, GDIPCONST REAL
* positions
, INT count
)
1309 REAL
*new_blendfac
, *new_blendpos
;
1311 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1313 if(!brush
|| !factors
|| !positions
|| count
<= 0 ||
1314 (count
>= 2 && (positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)))
1315 return InvalidParameter
;
1317 new_blendfac
= GdipAlloc(count
* sizeof(REAL
));
1318 new_blendpos
= GdipAlloc(count
* sizeof(REAL
));
1320 if (!new_blendfac
|| !new_blendpos
)
1322 GdipFree(new_blendfac
);
1323 GdipFree(new_blendpos
);
1327 memcpy(new_blendfac
, factors
, count
* sizeof(REAL
));
1328 memcpy(new_blendpos
, positions
, count
* sizeof(REAL
));
1330 GdipFree(brush
->blendfac
);
1331 GdipFree(brush
->blendpos
);
1333 brush
->blendcount
= count
;
1334 brush
->blendfac
= new_blendfac
;
1335 brush
->blendpos
= new_blendpos
;
1340 GpStatus WINGDIPAPI
GdipGetLineBlend(GpLineGradient
*brush
, REAL
*factors
,
1341 REAL
*positions
, INT count
)
1343 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1345 if (!brush
|| !factors
|| !positions
|| count
<= 0)
1346 return InvalidParameter
;
1348 if (count
< brush
->blendcount
)
1349 return InsufficientBuffer
;
1351 memcpy(factors
, brush
->blendfac
, brush
->blendcount
* sizeof(REAL
));
1352 memcpy(positions
, brush
->blendpos
, brush
->blendcount
* sizeof(REAL
));
1357 GpStatus WINGDIPAPI
GdipGetLineBlendCount(GpLineGradient
*brush
, INT
*count
)
1359 TRACE("(%p, %p)\n", brush
, count
);
1361 if (!brush
|| !count
)
1362 return InvalidParameter
;
1364 *count
= brush
->blendcount
;
1369 GpStatus WINGDIPAPI
GdipSetLineGammaCorrection(GpLineGradient
*line
,
1372 TRACE("(%p, %d)\n", line
, usegamma
);
1375 return InvalidParameter
;
1377 line
->gamma
= usegamma
;
1382 GpStatus WINGDIPAPI
GdipSetLineSigmaBlend(GpLineGradient
*line
, REAL focus
,
1389 const int precision
= 16;
1390 REAL erf_range
; /* we use values erf(-erf_range) through erf(+erf_range) */
1394 TRACE("(%p, %0.2f, %0.2f)\n", line
, focus
, scale
);
1396 if(!line
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1397 return InvalidParameter
;
1399 /* we want 2 standard deviations */
1400 erf_range
= 2.0 / sqrt(2);
1402 /* calculate the constants we need to normalize the error function to be
1403 between 0.0 and scale over the range we need */
1404 min_erf
= erf(-erf_range
);
1405 scale_erf
= scale
/ (-2.0 * min_erf
);
1411 for (i
=1; i
<precision
; i
++)
1413 positions
[i
] = focus
* i
/ precision
;
1414 factors
[i
] = scale_erf
* (erf(2 * erf_range
* i
/ precision
- erf_range
) - min_erf
);
1416 num_points
+= precision
;
1419 positions
[num_points
] = focus
;
1420 factors
[num_points
] = scale
;
1425 for (i
=1; i
<precision
; i
++)
1427 positions
[i
+num_points
-1] = (focus
+ ((1.0-focus
) * i
/ precision
));
1428 factors
[i
+num_points
-1] = scale_erf
* (erf(erf_range
- 2 * erf_range
* i
/ precision
) - min_erf
);
1430 num_points
+= precision
;
1431 positions
[num_points
-1] = 1.0;
1432 factors
[num_points
-1] = 0.0;
1435 return GdipSetLineBlend(line
, factors
, positions
, num_points
);
1438 GpStatus WINGDIPAPI
GdipSetLineWrapMode(GpLineGradient
*line
,
1441 TRACE("(%p, %d)\n", line
, wrap
);
1443 if(!line
|| wrap
== WrapModeClamp
)
1444 return InvalidParameter
;
1451 GpStatus WINGDIPAPI
GdipSetPathGradientBlend(GpPathGradient
*brush
, GDIPCONST REAL
*blend
,
1452 GDIPCONST REAL
*pos
, INT count
)
1456 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, pos
, count
);
1459 FIXME("not implemented\n");
1461 return NotImplemented
;
1464 GpStatus WINGDIPAPI
GdipSetPathGradientPresetBlend(GpPathGradient
*brush
,
1465 GDIPCONST ARGB
*blend
, GDIPCONST REAL
*pos
, INT count
)
1467 FIXME("(%p,%p,%p,%i): stub\n", brush
, blend
, pos
, count
);
1468 return NotImplemented
;
1471 GpStatus WINGDIPAPI
GdipSetPathGradientCenterColor(GpPathGradient
*grad
,
1474 TRACE("(%p, %x)\n", grad
, argb
);
1477 return InvalidParameter
;
1479 grad
->centercolor
= argb
;
1480 grad
->brush
.lb
.lbColor
= ARGB2COLORREF(argb
);
1482 DeleteObject(grad
->brush
.gdibrush
);
1483 grad
->brush
.gdibrush
= CreateSolidBrush(grad
->brush
.lb
.lbColor
);
1488 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPoint(GpPathGradient
*grad
,
1491 TRACE("(%p, %s)\n", grad
, debugstr_pointf(point
));
1494 return InvalidParameter
;
1496 grad
->center
.X
= point
->X
;
1497 grad
->center
.Y
= point
->Y
;
1502 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPointI(GpPathGradient
*grad
,
1507 TRACE("(%p, %p)\n", grad
, point
);
1510 return InvalidParameter
;
1512 ptf
.X
= (REAL
)point
->X
;
1513 ptf
.Y
= (REAL
)point
->Y
;
1515 return GdipSetPathGradientCenterPoint(grad
,&ptf
);
1518 GpStatus WINGDIPAPI
GdipSetPathGradientFocusScales(GpPathGradient
*grad
,
1521 TRACE("(%p, %.2f, %.2f)\n", grad
, x
, y
);
1524 return InvalidParameter
;
1532 GpStatus WINGDIPAPI
GdipSetPathGradientGammaCorrection(GpPathGradient
*grad
,
1535 TRACE("(%p, %d)\n", grad
, gamma
);
1538 return InvalidParameter
;
1540 grad
->gamma
= gamma
;
1545 GpStatus WINGDIPAPI
GdipSetPathGradientSigmaBlend(GpPathGradient
*grad
,
1546 REAL focus
, REAL scale
)
1550 TRACE("(%p,%0.2f,%0.2f)\n", grad
, focus
, scale
);
1552 if(!grad
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1553 return InvalidParameter
;
1556 FIXME("not implemented\n");
1558 return NotImplemented
;
1561 GpStatus WINGDIPAPI
GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1562 *grad
, ARGB
*argb
, INT
*count
)
1566 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1568 if(!grad
|| !argb
|| !count
|| (*count
<= 0) ||
1569 (*count
> grad
->pathdata
.Count
))
1570 return InvalidParameter
;
1573 FIXME("not implemented\n");
1575 return NotImplemented
;
1578 GpStatus WINGDIPAPI
GdipSetPathGradientWrapMode(GpPathGradient
*grad
,
1581 TRACE("(%p, %d)\n", grad
, wrap
);
1584 return InvalidParameter
;
1591 GpStatus WINGDIPAPI
GdipSetSolidFillColor(GpSolidFill
*sf
, ARGB argb
)
1593 TRACE("(%p, %x)\n", sf
, argb
);
1596 return InvalidParameter
;
1599 sf
->brush
.lb
.lbColor
= ARGB2COLORREF(argb
);
1601 DeleteObject(sf
->brush
.gdibrush
);
1602 sf
->brush
.gdibrush
= CreateSolidBrush(sf
->brush
.lb
.lbColor
);
1607 /******************************************************************************
1608 * GdipSetTextureTransform [GDIPLUS.@]
1610 GpStatus WINGDIPAPI
GdipSetTextureTransform(GpTexture
*texture
,
1611 GDIPCONST GpMatrix
*matrix
)
1613 TRACE("(%p, %p)\n", texture
, matrix
);
1615 if(!texture
|| !matrix
)
1616 return InvalidParameter
;
1618 memcpy(texture
->transform
, matrix
, sizeof(GpMatrix
));
1623 /******************************************************************************
1624 * GdipSetTextureWrapMode [GDIPLUS.@]
1626 * WrapMode not used, only stored
1628 GpStatus WINGDIPAPI
GdipSetTextureWrapMode(GpTexture
*brush
, GpWrapMode wrapmode
)
1630 TRACE("(%p, %d)\n", brush
, wrapmode
);
1633 return InvalidParameter
;
1635 brush
->wrap
= wrapmode
;
1640 GpStatus WINGDIPAPI
GdipSetLineColors(GpLineGradient
*brush
, ARGB color1
,
1643 TRACE("(%p, %x, %x)\n", brush
, color1
, color2
);
1646 return InvalidParameter
;
1648 brush
->startcolor
= color1
;
1649 brush
->endcolor
= color2
;
1654 GpStatus WINGDIPAPI
GdipGetLineColors(GpLineGradient
*brush
, ARGB
*colors
)
1656 TRACE("(%p, %p)\n", brush
, colors
);
1658 if(!brush
|| !colors
)
1659 return InvalidParameter
;
1661 colors
[0] = brush
->startcolor
;
1662 colors
[1] = brush
->endcolor
;
1667 /******************************************************************************
1668 * GdipRotateTextureTransform [GDIPLUS.@]
1670 GpStatus WINGDIPAPI
GdipRotateTextureTransform(GpTexture
* brush
, REAL angle
,
1671 GpMatrixOrder order
)
1673 TRACE("(%p, %.2f, %d)\n", brush
, angle
, order
);
1676 return InvalidParameter
;
1678 return GdipRotateMatrix(brush
->transform
, angle
, order
);
1681 GpStatus WINGDIPAPI
GdipSetLineLinearBlend(GpLineGradient
*brush
, REAL focus
,
1688 TRACE("(%p,%.2f,%.2f)\n", brush
, focus
, scale
);
1690 if (!brush
) return InvalidParameter
;
1694 factors
[num_points
] = 0.0;
1695 positions
[num_points
] = 0.0;
1699 factors
[num_points
] = scale
;
1700 positions
[num_points
] = focus
;
1705 factors
[num_points
] = 0.0;
1706 positions
[num_points
] = 1.0;
1710 return GdipSetLineBlend(brush
, factors
, positions
, num_points
);
1713 GpStatus WINGDIPAPI
GdipSetLinePresetBlend(GpLineGradient
*brush
,
1714 GDIPCONST ARGB
*blend
, GDIPCONST REAL
* positions
, INT count
)
1718 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, positions
, count
);
1720 if (!brush
|| !blend
|| !positions
|| count
< 2 ||
1721 positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)
1723 return InvalidParameter
;
1726 new_color
= GdipAlloc(count
* sizeof(ARGB
));
1727 new_pos
= GdipAlloc(count
* sizeof(REAL
));
1728 if (!new_color
|| !new_pos
)
1730 GdipFree(new_color
);
1735 memcpy(new_color
, blend
, sizeof(ARGB
) * count
);
1736 memcpy(new_pos
, positions
, sizeof(REAL
) * count
);
1738 GdipFree(brush
->pblendcolor
);
1739 GdipFree(brush
->pblendpos
);
1741 brush
->pblendcolor
= new_color
;
1742 brush
->pblendpos
= new_pos
;
1743 brush
->pblendcount
= count
;
1748 GpStatus WINGDIPAPI
GdipGetLinePresetBlend(GpLineGradient
*brush
,
1749 ARGB
*blend
, REAL
* positions
, INT count
)
1751 if (!brush
|| !blend
|| !positions
|| count
< 2)
1752 return InvalidParameter
;
1754 if (brush
->pblendcount
== 0)
1755 return GenericError
;
1757 if (count
< brush
->pblendcount
)
1758 return InsufficientBuffer
;
1760 memcpy(blend
, brush
->pblendcolor
, sizeof(ARGB
) * brush
->pblendcount
);
1761 memcpy(positions
, brush
->pblendpos
, sizeof(REAL
) * brush
->pblendcount
);
1766 GpStatus WINGDIPAPI
GdipGetLinePresetBlendCount(GpLineGradient
*brush
,
1769 if (!brush
|| !count
)
1770 return InvalidParameter
;
1772 *count
= brush
->pblendcount
;
1777 GpStatus WINGDIPAPI
GdipResetLineTransform(GpLineGradient
*brush
)
1781 TRACE("(%p)\n", brush
);
1784 FIXME("not implemented\n");
1786 return NotImplemented
;
1789 GpStatus WINGDIPAPI
GdipSetLineTransform(GpLineGradient
*brush
,
1790 GDIPCONST GpMatrix
*matrix
)
1794 TRACE("(%p,%p)\n", brush
, matrix
);
1797 FIXME("not implemented\n");
1799 return NotImplemented
;
1802 GpStatus WINGDIPAPI
GdipScaleLineTransform(GpLineGradient
*brush
, REAL sx
, REAL sy
,
1803 GpMatrixOrder order
)
1807 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush
, sx
, sy
, order
);
1810 FIXME("not implemented\n");
1812 return NotImplemented
;
1815 GpStatus WINGDIPAPI
GdipTranslateLineTransform(GpLineGradient
* brush
,
1816 REAL dx
, REAL dy
, GpMatrixOrder order
)
1818 FIXME("stub: %p %f %f %d\n", brush
, dx
, dy
, order
);
1820 return NotImplemented
;
1823 /******************************************************************************
1824 * GdipTranslateTextureTransform [GDIPLUS.@]
1826 GpStatus WINGDIPAPI
GdipTranslateTextureTransform(GpTexture
* brush
, REAL dx
, REAL dy
,
1827 GpMatrixOrder order
)
1829 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, dx
, dy
, order
);
1832 return InvalidParameter
;
1834 return GdipTranslateMatrix(brush
->transform
, dx
, dy
, order
);
1837 GpStatus WINGDIPAPI
GdipGetLineRect(GpLineGradient
*brush
, GpRectF
*rect
)
1839 TRACE("(%p, %p)\n", brush
, rect
);
1842 return InvalidParameter
;
1844 *rect
= brush
->rect
;
1849 GpStatus WINGDIPAPI
GdipGetLineRectI(GpLineGradient
*brush
, GpRect
*rect
)
1854 TRACE("(%p, %p)\n", brush
, rect
);
1857 return InvalidParameter
;
1859 ret
= GdipGetLineRect(brush
, &rectF
);
1862 rect
->X
= roundr(rectF
.X
);
1863 rect
->Y
= roundr(rectF
.Y
);
1864 rect
->Width
= roundr(rectF
.Width
);
1865 rect
->Height
= roundr(rectF
.Height
);
1871 GpStatus WINGDIPAPI
GdipRotateLineTransform(GpLineGradient
* brush
,
1872 REAL angle
, GpMatrixOrder order
)
1876 TRACE("(%p,%0.2f,%u)\n", brush
, angle
, order
);
1879 return InvalidParameter
;
1882 FIXME("(%p, %.2f, %d) stub\n", brush
, angle
, order
);
1884 return NotImplemented
;