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
);
37 /******************************************************************************
38 * GdipCloneBrush [GDIPLUS.@]
40 GpStatus WINGDIPAPI
GdipCloneBrush(GpBrush
*brush
, GpBrush
**clone
)
42 TRACE("(%p, %p)\n", brush
, clone
);
45 return InvalidParameter
;
48 case BrushTypeSolidColor
:
51 *clone
= GdipAlloc(sizeof(GpSolidFill
));
52 if (!*clone
) return OutOfMemory
;
54 fill
= (GpSolidFill
*)*clone
;
56 memcpy(*clone
, brush
, sizeof(GpSolidFill
));
58 (*clone
)->gdibrush
= CreateBrushIndirect(&(*clone
)->lb
);
59 fill
->bmp
= ARGB2BMP(fill
->color
);
62 case BrushTypeHatchFill
:
64 GpHatch
*hatch
= (GpHatch
*)brush
;
66 return GdipCreateHatchBrush(hatch
->hatchstyle
, hatch
->forecol
, hatch
->backcol
, (GpHatch
**)clone
);
68 case BrushTypePathGradient
:{
69 GpPathGradient
*src
, *dest
;
72 *clone
= GdipAlloc(sizeof(GpPathGradient
));
73 if (!*clone
) return OutOfMemory
;
75 src
= (GpPathGradient
*) brush
,
76 dest
= (GpPathGradient
*) *clone
;
77 count
= src
->pathdata
.Count
;
79 memcpy(dest
, src
, sizeof(GpPathGradient
));
81 dest
->pathdata
.Count
= count
;
82 dest
->pathdata
.Points
= GdipAlloc(count
* sizeof(PointF
));
83 dest
->pathdata
.Types
= GdipAlloc(count
);
85 if(!dest
->pathdata
.Points
|| !dest
->pathdata
.Types
){
86 GdipFree(dest
->pathdata
.Points
);
87 GdipFree(dest
->pathdata
.Types
);
92 memcpy(dest
->pathdata
.Points
, src
->pathdata
.Points
, count
* sizeof(PointF
));
93 memcpy(dest
->pathdata
.Types
, src
->pathdata
.Types
, count
);
96 count
= src
->blendcount
;
97 dest
->blendcount
= count
;
98 dest
->blendfac
= GdipAlloc(count
* sizeof(REAL
));
99 dest
->blendpos
= GdipAlloc(count
* sizeof(REAL
));
101 if(!dest
->blendfac
|| !dest
->blendpos
){
102 GdipFree(dest
->pathdata
.Points
);
103 GdipFree(dest
->pathdata
.Types
);
104 GdipFree(dest
->blendfac
);
105 GdipFree(dest
->blendpos
);
110 memcpy(dest
->blendfac
, src
->blendfac
, count
* sizeof(REAL
));
111 memcpy(dest
->blendpos
, src
->blendpos
, count
* sizeof(REAL
));
115 case BrushTypeLinearGradient
:{
116 GpLineGradient
*dest
, *src
;
119 dest
= GdipAlloc(sizeof(GpLineGradient
));
120 if(!dest
) return OutOfMemory
;
122 src
= (GpLineGradient
*)brush
;
124 memcpy(dest
, src
, sizeof(GpLineGradient
));
126 dest
->brush
.gdibrush
= CreateSolidBrush(dest
->brush
.lb
.lbColor
);
128 count
= dest
->blendcount
;
129 dest
->blendfac
= GdipAlloc(count
* sizeof(REAL
));
130 dest
->blendpos
= GdipAlloc(count
* sizeof(REAL
));
131 pcount
= dest
->pblendcount
;
134 dest
->pblendcolor
= GdipAlloc(pcount
* sizeof(ARGB
));
135 dest
->pblendpos
= GdipAlloc(pcount
* sizeof(REAL
));
138 if (!dest
->blendfac
|| !dest
->blendpos
||
139 (pcount
&& (!dest
->pblendcolor
|| !dest
->pblendpos
)))
141 GdipFree(dest
->blendfac
);
142 GdipFree(dest
->blendpos
);
143 GdipFree(dest
->pblendcolor
);
144 GdipFree(dest
->pblendpos
);
145 DeleteObject(dest
->brush
.gdibrush
);
150 memcpy(dest
->blendfac
, src
->blendfac
, count
* sizeof(REAL
));
151 memcpy(dest
->blendpos
, src
->blendpos
, count
* sizeof(REAL
));
155 memcpy(dest
->pblendcolor
, src
->pblendcolor
, pcount
* sizeof(ARGB
));
156 memcpy(dest
->pblendpos
, src
->pblendpos
, pcount
* sizeof(REAL
));
159 *clone
= &dest
->brush
;
162 case BrushTypeTextureFill
:
165 GpTexture
*texture
= (GpTexture
*)brush
;
166 GpTexture
*new_texture
;
168 stat
= GdipCreateTexture(texture
->image
, texture
->wrap
, &new_texture
);
172 memcpy(new_texture
->transform
, texture
->transform
, sizeof(GpMatrix
));
173 *clone
= (GpBrush
*)new_texture
;
181 ERR("not implemented for brush type %d\n", brush
->bt
);
182 return NotImplemented
;
185 TRACE("<-- %p\n", *clone
);
189 static const char HatchBrushes
[][8] = {
190 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
191 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
192 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
193 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
194 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
195 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
196 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
197 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
198 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
199 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
200 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
201 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
202 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
203 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
204 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
205 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
206 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
207 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
208 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
209 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
210 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
211 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
212 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
213 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
214 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
215 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
216 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
217 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
218 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
219 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
222 /******************************************************************************
223 * GdipCreateHatchBrush [GDIPLUS.@]
225 GpStatus WINGDIPAPI
GdipCreateHatchBrush(HatchStyle hatchstyle
, ARGB forecol
, ARGB backcol
, GpHatch
**brush
)
227 COLORREF fgcol
= ARGB2COLORREF(forecol
);
230 TRACE("(%d, %d, %d, %p)\n", hatchstyle
, forecol
, backcol
, brush
);
232 if(!brush
) return InvalidParameter
;
234 *brush
= GdipAlloc(sizeof(GpHatch
));
235 if (!*brush
) return OutOfMemory
;
237 if (hatchstyle
< sizeof(HatchBrushes
) / sizeof(HatchBrushes
[0]))
241 BITMAPINFOHEADER bmih
;
245 hdc
= CreateCompatibleDC(0);
249 bmih
.biSize
= sizeof(bmih
);
253 bmih
.biBitCount
= 32;
254 bmih
.biCompression
= BI_RGB
;
255 bmih
.biSizeImage
= 0;
257 hbmp
= CreateDIBSection(hdc
, (BITMAPINFO
*)&bmih
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0);
263 if ((HatchBrushes
[hatchstyle
][y
] & (0x80 >> x
)) != 0)
264 bits
[y
*8+x
] = forecol
;
266 bits
[y
*8+x
] = backcol
;
278 (*brush
)->brush
.lb
.lbStyle
= BS_PATTERN
;
279 (*brush
)->brush
.lb
.lbColor
= 0;
280 (*brush
)->brush
.lb
.lbHatch
= (ULONG_PTR
)hbmp
;
281 (*brush
)->brush
.gdibrush
= CreateBrushIndirect(&(*brush
)->brush
.lb
);
288 FIXME("Unimplemented hatch style %d\n", hatchstyle
);
290 (*brush
)->brush
.lb
.lbStyle
= BS_SOLID
;
291 (*brush
)->brush
.lb
.lbColor
= fgcol
;
292 (*brush
)->brush
.lb
.lbHatch
= 0;
293 (*brush
)->brush
.gdibrush
= CreateBrushIndirect(&(*brush
)->brush
.lb
);
298 (*brush
)->brush
.bt
= BrushTypeHatchFill
;
299 (*brush
)->forecol
= forecol
;
300 (*brush
)->backcol
= backcol
;
301 (*brush
)->hatchstyle
= hatchstyle
;
302 TRACE("<-- %p\n", *brush
);
313 /******************************************************************************
314 * GdipCreateLineBrush [GDIPLUS.@]
316 GpStatus WINGDIPAPI
GdipCreateLineBrush(GDIPCONST GpPointF
* startpoint
,
317 GDIPCONST GpPointF
* endpoint
, ARGB startcolor
, ARGB endcolor
,
318 GpWrapMode wrap
, GpLineGradient
**line
)
320 COLORREF col
= ARGB2COLORREF(startcolor
);
322 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint
),
323 debugstr_pointf(endpoint
), startcolor
, endcolor
, wrap
, line
);
325 if(!line
|| !startpoint
|| !endpoint
|| wrap
== WrapModeClamp
)
326 return InvalidParameter
;
328 if (startpoint
->X
== endpoint
->X
&& startpoint
->Y
== endpoint
->Y
)
331 *line
= GdipAlloc(sizeof(GpLineGradient
));
332 if(!*line
) return OutOfMemory
;
334 (*line
)->brush
.lb
.lbStyle
= BS_SOLID
;
335 (*line
)->brush
.lb
.lbColor
= col
;
336 (*line
)->brush
.lb
.lbHatch
= 0;
337 (*line
)->brush
.gdibrush
= CreateSolidBrush(col
);
338 (*line
)->brush
.bt
= BrushTypeLinearGradient
;
340 (*line
)->startpoint
.X
= startpoint
->X
;
341 (*line
)->startpoint
.Y
= startpoint
->Y
;
342 (*line
)->endpoint
.X
= endpoint
->X
;
343 (*line
)->endpoint
.Y
= endpoint
->Y
;
344 (*line
)->startcolor
= startcolor
;
345 (*line
)->endcolor
= endcolor
;
346 (*line
)->wrap
= wrap
;
347 (*line
)->gamma
= FALSE
;
349 (*line
)->rect
.X
= (startpoint
->X
< endpoint
->X
? startpoint
->X
: endpoint
->X
);
350 (*line
)->rect
.Y
= (startpoint
->Y
< endpoint
->Y
? startpoint
->Y
: endpoint
->Y
);
351 (*line
)->rect
.Width
= fabs(startpoint
->X
- endpoint
->X
);
352 (*line
)->rect
.Height
= fabs(startpoint
->Y
- endpoint
->Y
);
354 if ((*line
)->rect
.Width
== 0)
356 (*line
)->rect
.X
-= (*line
)->rect
.Height
/ 2.0f
;
357 (*line
)->rect
.Width
= (*line
)->rect
.Height
;
359 else if ((*line
)->rect
.Height
== 0)
361 (*line
)->rect
.Y
-= (*line
)->rect
.Width
/ 2.0f
;
362 (*line
)->rect
.Height
= (*line
)->rect
.Width
;
365 (*line
)->blendcount
= 1;
366 (*line
)->blendfac
= GdipAlloc(sizeof(REAL
));
367 (*line
)->blendpos
= GdipAlloc(sizeof(REAL
));
369 if (!(*line
)->blendfac
|| !(*line
)->blendpos
)
371 GdipFree((*line
)->blendfac
);
372 GdipFree((*line
)->blendpos
);
373 DeleteObject((*line
)->brush
.gdibrush
);
379 (*line
)->blendfac
[0] = 1.0f
;
380 (*line
)->blendpos
[0] = 1.0f
;
382 (*line
)->pblendcolor
= NULL
;
383 (*line
)->pblendpos
= NULL
;
384 (*line
)->pblendcount
= 0;
386 TRACE("<-- %p\n", *line
);
391 GpStatus WINGDIPAPI
GdipCreateLineBrushI(GDIPCONST GpPoint
* startpoint
,
392 GDIPCONST GpPoint
* endpoint
, ARGB startcolor
, ARGB endcolor
,
393 GpWrapMode wrap
, GpLineGradient
**line
)
398 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint
, endpoint
,
399 startcolor
, endcolor
, wrap
, line
);
401 if(!startpoint
|| !endpoint
)
402 return InvalidParameter
;
404 stF
.X
= (REAL
)startpoint
->X
;
405 stF
.Y
= (REAL
)startpoint
->Y
;
406 endF
.X
= (REAL
)endpoint
->X
;
407 endF
.Y
= (REAL
)endpoint
->Y
;
409 return GdipCreateLineBrush(&stF
, &endF
, startcolor
, endcolor
, wrap
, line
);
412 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRect(GDIPCONST GpRectF
* rect
,
413 ARGB startcolor
, ARGB endcolor
, LinearGradientMode mode
, GpWrapMode wrap
,
414 GpLineGradient
**line
)
419 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect
, startcolor
, endcolor
, mode
,
423 return InvalidParameter
;
427 case LinearGradientModeHorizontal
:
430 end
.X
= rect
->X
+ rect
->Width
;
433 case LinearGradientModeVertical
:
437 end
.Y
= rect
->Y
+ rect
->Height
;
439 case LinearGradientModeForwardDiagonal
:
442 end
.X
= rect
->X
+ rect
->Width
;
443 end
.Y
= rect
->Y
+ rect
->Height
;
445 case LinearGradientModeBackwardDiagonal
:
446 start
.X
= rect
->X
+ rect
->Width
;
449 end
.Y
= rect
->Y
+ rect
->Height
;
452 return InvalidParameter
;
455 stat
= GdipCreateLineBrush(&start
, &end
, startcolor
, endcolor
, wrap
, line
);
458 (*line
)->rect
= *rect
;
463 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectI(GDIPCONST GpRect
* rect
,
464 ARGB startcolor
, ARGB endcolor
, LinearGradientMode mode
, GpWrapMode wrap
,
465 GpLineGradient
**line
)
469 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect
, startcolor
, endcolor
, mode
,
472 rectF
.X
= (REAL
) rect
->X
;
473 rectF
.Y
= (REAL
) rect
->Y
;
474 rectF
.Width
= (REAL
) rect
->Width
;
475 rectF
.Height
= (REAL
) rect
->Height
;
477 return GdipCreateLineBrushFromRect(&rectF
, startcolor
, endcolor
, mode
, wrap
, line
);
480 /******************************************************************************
481 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
483 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF
* rect
,
484 ARGB startcolor
, ARGB endcolor
, REAL angle
, BOOL isAngleScalable
, GpWrapMode wrap
,
485 GpLineGradient
**line
)
488 LinearGradientMode mode
;
489 REAL width
, height
, exofs
, eyofs
;
490 REAL sin_angle
, cos_angle
, sin_cos_angle
;
492 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect
, startcolor
, endcolor
, angle
, isAngleScalable
,
495 sin_angle
= sinf(deg2rad(angle
));
496 cos_angle
= cosf(deg2rad(angle
));
497 sin_cos_angle
= sin_angle
* cos_angle
;
501 width
= height
= 1.0;
506 height
= rect
->Height
;
509 if (sin_cos_angle
>= 0)
510 mode
= LinearGradientModeForwardDiagonal
;
512 mode
= LinearGradientModeBackwardDiagonal
;
514 stat
= GdipCreateLineBrushFromRect(rect
, startcolor
, endcolor
, mode
, wrap
, line
);
518 if (sin_cos_angle
>= 0)
520 exofs
= width
* sin_cos_angle
+ height
* cos_angle
* cos_angle
;
521 eyofs
= width
* sin_angle
* sin_angle
+ height
* sin_cos_angle
;
525 exofs
= width
* sin_angle
* sin_angle
+ height
* sin_cos_angle
;
526 eyofs
= -width
* sin_cos_angle
+ height
* sin_angle
* sin_angle
;
531 exofs
= exofs
* rect
->Width
;
532 eyofs
= eyofs
* rect
->Height
;
537 (*line
)->endpoint
.X
= rect
->X
+ exofs
;
538 (*line
)->endpoint
.Y
= rect
->Y
+ eyofs
;
542 (*line
)->endpoint
.X
= (*line
)->startpoint
.X
;
543 (*line
)->endpoint
.Y
= (*line
)->startpoint
.Y
;
544 (*line
)->startpoint
.X
= rect
->X
+ exofs
;
545 (*line
)->startpoint
.Y
= rect
->Y
+ eyofs
;
552 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect
* rect
,
553 ARGB startcolor
, ARGB endcolor
, REAL angle
, BOOL isAngleScalable
, GpWrapMode wrap
,
554 GpLineGradient
**line
)
556 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect
, startcolor
, endcolor
, angle
, isAngleScalable
,
559 return GdipCreateLineBrushFromRectI(rect
, startcolor
, endcolor
, LinearGradientModeForwardDiagonal
,
563 GpStatus WINGDIPAPI
GdipCreatePathGradient(GDIPCONST GpPointF
* points
,
564 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
566 COLORREF col
= ARGB2COLORREF(0xffffffff);
568 TRACE("(%p, %d, %d, %p)\n", points
, count
, wrap
, grad
);
571 return InvalidParameter
;
576 *grad
= GdipAlloc(sizeof(GpPathGradient
));
577 if (!*grad
) return OutOfMemory
;
579 (*grad
)->blendfac
= GdipAlloc(sizeof(REAL
));
580 (*grad
)->blendpos
= GdipAlloc(sizeof(REAL
));
581 if(!(*grad
)->blendfac
|| !(*grad
)->blendpos
){
582 GdipFree((*grad
)->blendfac
);
583 GdipFree((*grad
)->blendpos
);
588 (*grad
)->blendfac
[0] = 1.0;
589 (*grad
)->blendpos
[0] = 1.0;
590 (*grad
)->blendcount
= 1;
592 (*grad
)->pathdata
.Count
= count
;
593 (*grad
)->pathdata
.Points
= GdipAlloc(count
* sizeof(PointF
));
594 (*grad
)->pathdata
.Types
= GdipAlloc(count
);
596 if(!(*grad
)->pathdata
.Points
|| !(*grad
)->pathdata
.Types
){
597 GdipFree((*grad
)->pathdata
.Points
);
598 GdipFree((*grad
)->pathdata
.Types
);
603 memcpy((*grad
)->pathdata
.Points
, points
, count
* sizeof(PointF
));
604 memset((*grad
)->pathdata
.Types
, PathPointTypeLine
, count
);
606 (*grad
)->brush
.lb
.lbStyle
= BS_SOLID
;
607 (*grad
)->brush
.lb
.lbColor
= col
;
608 (*grad
)->brush
.lb
.lbHatch
= 0;
610 (*grad
)->brush
.gdibrush
= CreateSolidBrush(col
);
611 (*grad
)->brush
.bt
= BrushTypePathGradient
;
612 (*grad
)->centercolor
= 0xffffffff;
613 (*grad
)->wrap
= wrap
;
614 (*grad
)->gamma
= FALSE
;
615 (*grad
)->center
.X
= 0.0;
616 (*grad
)->center
.Y
= 0.0;
617 (*grad
)->focus
.X
= 0.0;
618 (*grad
)->focus
.Y
= 0.0;
620 TRACE("<-- %p\n", *grad
);
625 GpStatus WINGDIPAPI
GdipCreatePathGradientI(GDIPCONST GpPoint
* points
,
626 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
632 TRACE("(%p, %d, %d, %p)\n", points
, count
, wrap
, grad
);
635 return InvalidParameter
;
640 pointsF
= GdipAlloc(sizeof(GpPointF
) * count
);
644 for(i
= 0; i
< count
; i
++){
645 pointsF
[i
].X
= (REAL
)points
[i
].X
;
646 pointsF
[i
].Y
= (REAL
)points
[i
].Y
;
649 ret
= GdipCreatePathGradient(pointsF
, count
, wrap
, grad
);
655 /******************************************************************************
656 * GdipCreatePathGradientFromPath [GDIPLUS.@]
658 * FIXME: path gradient brushes not truly supported (drawn as solid brushes)
660 GpStatus WINGDIPAPI
GdipCreatePathGradientFromPath(GDIPCONST GpPath
* path
,
661 GpPathGradient
**grad
)
663 COLORREF col
= ARGB2COLORREF(0xffffffff);
665 TRACE("(%p, %p)\n", path
, grad
);
668 return InvalidParameter
;
670 *grad
= GdipAlloc(sizeof(GpPathGradient
));
671 if (!*grad
) return OutOfMemory
;
673 (*grad
)->blendfac
= GdipAlloc(sizeof(REAL
));
674 (*grad
)->blendpos
= GdipAlloc(sizeof(REAL
));
675 if(!(*grad
)->blendfac
|| !(*grad
)->blendpos
){
676 GdipFree((*grad
)->blendfac
);
677 GdipFree((*grad
)->blendpos
);
682 (*grad
)->blendfac
[0] = 1.0;
683 (*grad
)->blendpos
[0] = 1.0;
684 (*grad
)->blendcount
= 1;
686 (*grad
)->pathdata
.Count
= path
->pathdata
.Count
;
687 (*grad
)->pathdata
.Points
= GdipAlloc(path
->pathdata
.Count
* sizeof(PointF
));
688 (*grad
)->pathdata
.Types
= GdipAlloc(path
->pathdata
.Count
);
690 if(!(*grad
)->pathdata
.Points
|| !(*grad
)->pathdata
.Types
){
691 GdipFree((*grad
)->pathdata
.Points
);
692 GdipFree((*grad
)->pathdata
.Types
);
697 memcpy((*grad
)->pathdata
.Points
, path
->pathdata
.Points
,
698 path
->pathdata
.Count
* sizeof(PointF
));
699 memcpy((*grad
)->pathdata
.Types
, path
->pathdata
.Types
, path
->pathdata
.Count
);
701 (*grad
)->brush
.lb
.lbStyle
= BS_SOLID
;
702 (*grad
)->brush
.lb
.lbColor
= col
;
703 (*grad
)->brush
.lb
.lbHatch
= 0;
705 (*grad
)->brush
.gdibrush
= CreateSolidBrush(col
);
706 (*grad
)->brush
.bt
= BrushTypePathGradient
;
707 (*grad
)->centercolor
= 0xffffffff;
708 (*grad
)->wrap
= WrapModeClamp
;
709 (*grad
)->gamma
= FALSE
;
710 /* FIXME: this should be set to the "centroid" of the path by default */
711 (*grad
)->center
.X
= 0.0;
712 (*grad
)->center
.Y
= 0.0;
713 (*grad
)->focus
.X
= 0.0;
714 (*grad
)->focus
.Y
= 0.0;
716 TRACE("<-- %p\n", *grad
);
721 /******************************************************************************
722 * GdipCreateSolidFill [GDIPLUS.@]
724 GpStatus WINGDIPAPI
GdipCreateSolidFill(ARGB color
, GpSolidFill
**sf
)
726 COLORREF col
= ARGB2COLORREF(color
);
728 TRACE("(%x, %p)\n", color
, sf
);
730 if(!sf
) return InvalidParameter
;
732 *sf
= GdipAlloc(sizeof(GpSolidFill
));
733 if (!*sf
) return OutOfMemory
;
735 (*sf
)->brush
.lb
.lbStyle
= BS_SOLID
;
736 (*sf
)->brush
.lb
.lbColor
= col
;
737 (*sf
)->brush
.lb
.lbHatch
= 0;
739 (*sf
)->brush
.gdibrush
= CreateSolidBrush(col
);
740 (*sf
)->brush
.bt
= BrushTypeSolidColor
;
741 (*sf
)->color
= color
;
742 (*sf
)->bmp
= ARGB2BMP(color
);
744 TRACE("<-- %p\n", *sf
);
749 /******************************************************************************
750 * GdipCreateTexture [GDIPLUS.@]
753 * image [I] image to use
754 * wrapmode [I] optional
755 * texture [O] pointer to the resulting texturebrush
759 * FAILURE: element of GpStatus
761 GpStatus WINGDIPAPI
GdipCreateTexture(GpImage
*image
, GpWrapMode wrapmode
,
765 GpImageAttributes attributes
;
768 TRACE("%p, %d %p\n", image
, wrapmode
, texture
);
770 if (!(image
&& texture
))
771 return InvalidParameter
;
773 stat
= GdipGetImageWidth(image
, &width
);
774 if (stat
!= Ok
) return stat
;
775 stat
= GdipGetImageHeight(image
, &height
);
776 if (stat
!= Ok
) return stat
;
777 attributes
.wrap
= wrapmode
;
779 return GdipCreateTextureIA(image
, &attributes
, 0, 0, width
, height
,
783 /******************************************************************************
784 * GdipCreateTexture2 [GDIPLUS.@]
786 GpStatus WINGDIPAPI
GdipCreateTexture2(GpImage
*image
, GpWrapMode wrapmode
,
787 REAL x
, REAL y
, REAL width
, REAL height
, GpTexture
**texture
)
789 GpImageAttributes attributes
;
791 TRACE("%p %d %f %f %f %f %p\n", image
, wrapmode
,
792 x
, y
, width
, height
, texture
);
794 attributes
.wrap
= wrapmode
;
795 return GdipCreateTextureIA(image
, &attributes
, x
, y
, width
, height
,
799 /******************************************************************************
800 * GdipCreateTextureIA [GDIPLUS.@]
802 * FIXME: imageattr ignored
804 GpStatus WINGDIPAPI
GdipCreateTextureIA(GpImage
*image
,
805 GDIPCONST GpImageAttributes
*imageattr
, REAL x
, REAL y
, REAL width
,
806 REAL height
, GpTexture
**texture
)
810 GpImage
*new_image
=NULL
;
812 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image
, imageattr
, x
, y
, width
, height
,
815 if(!image
|| !texture
|| x
< 0.0 || y
< 0.0 || width
< 0.0 || height
< 0.0)
816 return InvalidParameter
;
820 if(image
->type
!= ImageTypeBitmap
){
821 FIXME("not implemented for image type %d\n", image
->type
);
822 return NotImplemented
;
825 status
= GdipCloneBitmapArea(x
, y
, width
, height
, PixelFormatDontCare
, (GpBitmap
*)image
, (GpBitmap
**)&new_image
);
829 status
= GdipCreateHBITMAPFromBitmap((GpBitmap
*)new_image
, &hbm
, 0);
832 status
= GenericError
;
836 *texture
= GdipAlloc(sizeof(GpTexture
));
838 status
= OutOfMemory
;
842 if((status
= GdipCreateMatrix(&(*texture
)->transform
)) != Ok
){
846 (*texture
)->brush
.lb
.lbStyle
= BS_PATTERN
;
847 (*texture
)->brush
.lb
.lbColor
= 0;
848 (*texture
)->brush
.lb
.lbHatch
= (ULONG_PTR
)hbm
;
850 (*texture
)->brush
.gdibrush
= CreateBrushIndirect(&(*texture
)->brush
.lb
);
851 (*texture
)->brush
.bt
= BrushTypeTextureFill
;
853 (*texture
)->wrap
= imageattr
->wrap
;
855 (*texture
)->wrap
= WrapModeTile
;
856 (*texture
)->image
= new_image
;
861 TRACE("<-- %p\n", *texture
);
867 GdipDeleteMatrix((*texture
)->transform
);
871 GdipDisposeImage(new_image
);
872 TRACE("<-- error %u\n", status
);
880 /******************************************************************************
881 * GdipCreateTextureIAI [GDIPLUS.@]
883 GpStatus WINGDIPAPI
GdipCreateTextureIAI(GpImage
*image
, GDIPCONST GpImageAttributes
*imageattr
,
884 INT x
, INT y
, INT width
, INT height
, GpTexture
**texture
)
886 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image
, imageattr
, x
, y
, width
, height
,
889 return GdipCreateTextureIA(image
,imageattr
,(REAL
)x
,(REAL
)y
,(REAL
)width
,(REAL
)height
,texture
);
892 GpStatus WINGDIPAPI
GdipCreateTexture2I(GpImage
*image
, GpWrapMode wrapmode
,
893 INT x
, INT y
, INT width
, INT height
, GpTexture
**texture
)
895 GpImageAttributes imageattr
;
897 TRACE("%p %d %d %d %d %d %p\n", image
, wrapmode
, x
, y
, width
, height
,
900 imageattr
.wrap
= wrapmode
;
902 return GdipCreateTextureIA(image
, &imageattr
, x
, y
, width
, height
, texture
);
905 GpStatus WINGDIPAPI
GdipGetBrushType(GpBrush
*brush
, GpBrushType
*type
)
907 TRACE("(%p, %p)\n", brush
, type
);
909 if(!brush
|| !type
) return InvalidParameter
;
916 GpStatus WINGDIPAPI
GdipGetHatchBackgroundColor(GpHatch
*brush
, ARGB
*backcol
)
918 TRACE("(%p, %p)\n", brush
, backcol
);
920 if(!brush
|| !backcol
) return InvalidParameter
;
922 *backcol
= brush
->backcol
;
927 GpStatus WINGDIPAPI
GdipGetHatchForegroundColor(GpHatch
*brush
, ARGB
*forecol
)
929 TRACE("(%p, %p)\n", brush
, forecol
);
931 if(!brush
|| !forecol
) return InvalidParameter
;
933 *forecol
= brush
->forecol
;
938 GpStatus WINGDIPAPI
GdipGetHatchStyle(GpHatch
*brush
, HatchStyle
*hatchstyle
)
940 TRACE("(%p, %p)\n", brush
, hatchstyle
);
942 if(!brush
|| !hatchstyle
) return InvalidParameter
;
944 *hatchstyle
= brush
->hatchstyle
;
949 GpStatus WINGDIPAPI
GdipDeleteBrush(GpBrush
*brush
)
951 TRACE("(%p)\n", brush
);
953 if(!brush
) return InvalidParameter
;
957 case BrushTypePathGradient
:
958 GdipFree(((GpPathGradient
*) brush
)->pathdata
.Points
);
959 GdipFree(((GpPathGradient
*) brush
)->pathdata
.Types
);
960 GdipFree(((GpPathGradient
*) brush
)->blendfac
);
961 GdipFree(((GpPathGradient
*) brush
)->blendpos
);
963 case BrushTypeSolidColor
:
964 if (((GpSolidFill
*)brush
)->bmp
)
965 DeleteObject(((GpSolidFill
*)brush
)->bmp
);
967 case BrushTypeLinearGradient
:
968 GdipFree(((GpLineGradient
*)brush
)->blendfac
);
969 GdipFree(((GpLineGradient
*)brush
)->blendpos
);
970 GdipFree(((GpLineGradient
*)brush
)->pblendcolor
);
971 GdipFree(((GpLineGradient
*)brush
)->pblendpos
);
973 case BrushTypeTextureFill
:
974 GdipDeleteMatrix(((GpTexture
*)brush
)->transform
);
975 GdipDisposeImage(((GpTexture
*)brush
)->image
);
981 DeleteObject(brush
->gdibrush
);
987 GpStatus WINGDIPAPI
GdipGetLineGammaCorrection(GpLineGradient
*line
,
990 TRACE("(%p, %p)\n", line
, usinggamma
);
992 if(!line
|| !usinggamma
)
993 return InvalidParameter
;
995 *usinggamma
= line
->gamma
;
1000 GpStatus WINGDIPAPI
GdipGetLineWrapMode(GpLineGradient
*brush
, GpWrapMode
*wrapmode
)
1002 TRACE("(%p, %p)\n", brush
, wrapmode
);
1004 if(!brush
|| !wrapmode
)
1005 return InvalidParameter
;
1007 *wrapmode
= brush
->wrap
;
1012 GpStatus WINGDIPAPI
GdipGetPathGradientBlend(GpPathGradient
*brush
, REAL
*blend
,
1013 REAL
*positions
, INT count
)
1015 TRACE("(%p, %p, %p, %d)\n", brush
, blend
, positions
, count
);
1017 if(!brush
|| !blend
|| !positions
|| count
<= 0)
1018 return InvalidParameter
;
1020 if(count
< brush
->blendcount
)
1021 return InsufficientBuffer
;
1023 memcpy(blend
, brush
->blendfac
, count
*sizeof(REAL
));
1024 if(brush
->blendcount
> 1){
1025 memcpy(positions
, brush
->blendpos
, count
*sizeof(REAL
));
1031 GpStatus WINGDIPAPI
GdipGetPathGradientBlendCount(GpPathGradient
*brush
, INT
*count
)
1033 TRACE("(%p, %p)\n", brush
, count
);
1035 if(!brush
|| !count
)
1036 return InvalidParameter
;
1038 *count
= brush
->blendcount
;
1043 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPoint(GpPathGradient
*grad
,
1046 TRACE("(%p, %p)\n", grad
, point
);
1049 return InvalidParameter
;
1051 point
->X
= grad
->center
.X
;
1052 point
->Y
= grad
->center
.Y
;
1057 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPointI(GpPathGradient
*grad
,
1063 TRACE("(%p, %p)\n", grad
, point
);
1066 return InvalidParameter
;
1068 ret
= GdipGetPathGradientCenterPoint(grad
,&ptf
);
1071 point
->X
= roundr(ptf
.X
);
1072 point
->Y
= roundr(ptf
.Y
);
1078 GpStatus WINGDIPAPI
GdipGetPathGradientCenterColor(GpPathGradient
*grad
,
1083 TRACE("(%p,%p)\n", grad
, colors
);
1086 FIXME("not implemented\n");
1088 return NotImplemented
;
1091 GpStatus WINGDIPAPI
GdipGetPathGradientFocusScales(GpPathGradient
*grad
,
1094 TRACE("(%p, %p, %p)\n", grad
, x
, y
);
1096 if(!grad
|| !x
|| !y
)
1097 return InvalidParameter
;
1105 GpStatus WINGDIPAPI
GdipGetPathGradientGammaCorrection(GpPathGradient
*grad
,
1108 TRACE("(%p, %p)\n", grad
, gamma
);
1111 return InvalidParameter
;
1113 *gamma
= grad
->gamma
;
1118 GpStatus WINGDIPAPI
GdipGetPathGradientPointCount(GpPathGradient
*grad
,
1121 TRACE("(%p, %p)\n", grad
, count
);
1124 return InvalidParameter
;
1126 *count
= grad
->pathdata
.Count
;
1131 GpStatus WINGDIPAPI
GdipGetPathGradientRect(GpPathGradient
*brush
, GpRectF
*rect
)
1137 TRACE("(%p, %p)\n", brush
, rect
);
1140 return InvalidParameter
;
1142 stat
= GdipCreatePath2(brush
->pathdata
.Points
, brush
->pathdata
.Types
,
1143 brush
->pathdata
.Count
, FillModeAlternate
, &path
);
1144 if(stat
!= Ok
) return stat
;
1146 stat
= GdipGetPathWorldBounds(path
, &r
, NULL
, NULL
);
1148 GdipDeletePath(path
);
1152 memcpy(rect
, &r
, sizeof(GpRectF
));
1154 GdipDeletePath(path
);
1159 GpStatus WINGDIPAPI
GdipGetPathGradientRectI(GpPathGradient
*brush
, GpRect
*rect
)
1164 TRACE("(%p, %p)\n", brush
, rect
);
1167 return InvalidParameter
;
1169 stat
= GdipGetPathGradientRect(brush
, &rectf
);
1170 if(stat
!= Ok
) return stat
;
1172 rect
->X
= roundr(rectf
.X
);
1173 rect
->Y
= roundr(rectf
.Y
);
1174 rect
->Width
= roundr(rectf
.Width
);
1175 rect
->Height
= roundr(rectf
.Height
);
1180 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1181 *grad
, ARGB
*argb
, INT
*count
)
1185 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1187 if(!grad
|| !argb
|| !count
|| (*count
< grad
->pathdata
.Count
))
1188 return InvalidParameter
;
1191 FIXME("not implemented\n");
1193 return NotImplemented
;
1196 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorCount(GpPathGradient
*brush
, INT
*count
)
1198 TRACE("(%p, %p)\n", brush
, count
);
1200 if (!brush
|| !count
)
1201 return InvalidParameter
;
1203 return NotImplemented
;
1206 GpStatus WINGDIPAPI
GdipGetPathGradientWrapMode(GpPathGradient
*brush
,
1207 GpWrapMode
*wrapmode
)
1209 TRACE("(%p, %p)\n", brush
, wrapmode
);
1211 if(!brush
|| !wrapmode
)
1212 return InvalidParameter
;
1214 *wrapmode
= brush
->wrap
;
1219 GpStatus WINGDIPAPI
GdipGetSolidFillColor(GpSolidFill
*sf
, ARGB
*argb
)
1221 TRACE("(%p, %p)\n", sf
, argb
);
1224 return InvalidParameter
;
1231 /******************************************************************************
1232 * GdipGetTextureImage [GDIPLUS.@]
1234 GpStatus WINGDIPAPI
GdipGetTextureImage(GpTexture
*brush
, GpImage
**image
)
1236 TRACE("(%p, %p)\n", brush
, image
);
1238 if(!brush
|| !image
)
1239 return InvalidParameter
;
1241 return GdipCloneImage(brush
->image
, image
);
1244 /******************************************************************************
1245 * GdipGetTextureTransform [GDIPLUS.@]
1247 GpStatus WINGDIPAPI
GdipGetTextureTransform(GpTexture
*brush
, GpMatrix
*matrix
)
1249 TRACE("(%p, %p)\n", brush
, matrix
);
1251 if(!brush
|| !matrix
)
1252 return InvalidParameter
;
1254 memcpy(matrix
, brush
->transform
, sizeof(GpMatrix
));
1259 /******************************************************************************
1260 * GdipGetTextureWrapMode [GDIPLUS.@]
1262 GpStatus WINGDIPAPI
GdipGetTextureWrapMode(GpTexture
*brush
, GpWrapMode
*wrapmode
)
1264 TRACE("(%p, %p)\n", brush
, wrapmode
);
1266 if(!brush
|| !wrapmode
)
1267 return InvalidParameter
;
1269 *wrapmode
= brush
->wrap
;
1274 /******************************************************************************
1275 * GdipMultiplyTextureTransform [GDIPLUS.@]
1277 GpStatus WINGDIPAPI
GdipMultiplyTextureTransform(GpTexture
* brush
,
1278 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1280 TRACE("(%p, %p, %d)\n", brush
, matrix
, order
);
1282 if(!brush
|| !matrix
)
1283 return InvalidParameter
;
1285 return GdipMultiplyMatrix(brush
->transform
, matrix
, order
);
1288 /******************************************************************************
1289 * GdipResetTextureTransform [GDIPLUS.@]
1291 GpStatus WINGDIPAPI
GdipResetTextureTransform(GpTexture
* brush
)
1293 TRACE("(%p)\n", brush
);
1296 return InvalidParameter
;
1298 return GdipSetMatrixElements(brush
->transform
, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1301 /******************************************************************************
1302 * GdipScaleTextureTransform [GDIPLUS.@]
1304 GpStatus WINGDIPAPI
GdipScaleTextureTransform(GpTexture
* brush
,
1305 REAL sx
, REAL sy
, GpMatrixOrder order
)
1307 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, sx
, sy
, order
);
1310 return InvalidParameter
;
1312 return GdipScaleMatrix(brush
->transform
, sx
, sy
, order
);
1315 GpStatus WINGDIPAPI
GdipSetLineBlend(GpLineGradient
*brush
,
1316 GDIPCONST REAL
*factors
, GDIPCONST REAL
* positions
, INT count
)
1318 REAL
*new_blendfac
, *new_blendpos
;
1320 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1322 if(!brush
|| !factors
|| !positions
|| count
<= 0 ||
1323 (count
>= 2 && (positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)))
1324 return InvalidParameter
;
1326 new_blendfac
= GdipAlloc(count
* sizeof(REAL
));
1327 new_blendpos
= GdipAlloc(count
* sizeof(REAL
));
1329 if (!new_blendfac
|| !new_blendpos
)
1331 GdipFree(new_blendfac
);
1332 GdipFree(new_blendpos
);
1336 memcpy(new_blendfac
, factors
, count
* sizeof(REAL
));
1337 memcpy(new_blendpos
, positions
, count
* sizeof(REAL
));
1339 GdipFree(brush
->blendfac
);
1340 GdipFree(brush
->blendpos
);
1342 brush
->blendcount
= count
;
1343 brush
->blendfac
= new_blendfac
;
1344 brush
->blendpos
= new_blendpos
;
1349 GpStatus WINGDIPAPI
GdipGetLineBlend(GpLineGradient
*brush
, REAL
*factors
,
1350 REAL
*positions
, INT count
)
1352 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1354 if (!brush
|| !factors
|| !positions
|| count
<= 0)
1355 return InvalidParameter
;
1357 if (count
< brush
->blendcount
)
1358 return InsufficientBuffer
;
1360 memcpy(factors
, brush
->blendfac
, brush
->blendcount
* sizeof(REAL
));
1361 memcpy(positions
, brush
->blendpos
, brush
->blendcount
* sizeof(REAL
));
1366 GpStatus WINGDIPAPI
GdipGetLineBlendCount(GpLineGradient
*brush
, INT
*count
)
1368 TRACE("(%p, %p)\n", brush
, count
);
1370 if (!brush
|| !count
)
1371 return InvalidParameter
;
1373 *count
= brush
->blendcount
;
1378 GpStatus WINGDIPAPI
GdipSetLineGammaCorrection(GpLineGradient
*line
,
1381 TRACE("(%p, %d)\n", line
, usegamma
);
1384 return InvalidParameter
;
1386 line
->gamma
= usegamma
;
1391 GpStatus WINGDIPAPI
GdipSetLineSigmaBlend(GpLineGradient
*line
, REAL focus
,
1398 const int precision
= 16;
1399 REAL erf_range
; /* we use values erf(-erf_range) through erf(+erf_range) */
1403 TRACE("(%p, %0.2f, %0.2f)\n", line
, focus
, scale
);
1405 if(!line
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1406 return InvalidParameter
;
1408 /* we want 2 standard deviations */
1409 erf_range
= 2.0 / sqrt(2);
1411 /* calculate the constants we need to normalize the error function to be
1412 between 0.0 and scale over the range we need */
1413 min_erf
= erf(-erf_range
);
1414 scale_erf
= scale
/ (-2.0 * min_erf
);
1420 for (i
=1; i
<precision
; i
++)
1422 positions
[i
] = focus
* i
/ precision
;
1423 factors
[i
] = scale_erf
* (erf(2 * erf_range
* i
/ precision
- erf_range
) - min_erf
);
1425 num_points
+= precision
;
1428 positions
[num_points
] = focus
;
1429 factors
[num_points
] = scale
;
1434 for (i
=1; i
<precision
; i
++)
1436 positions
[i
+num_points
-1] = (focus
+ ((1.0-focus
) * i
/ precision
));
1437 factors
[i
+num_points
-1] = scale_erf
* (erf(erf_range
- 2 * erf_range
* i
/ precision
) - min_erf
);
1439 num_points
+= precision
;
1440 positions
[num_points
-1] = 1.0;
1441 factors
[num_points
-1] = 0.0;
1444 return GdipSetLineBlend(line
, factors
, positions
, num_points
);
1447 GpStatus WINGDIPAPI
GdipSetLineWrapMode(GpLineGradient
*line
,
1450 TRACE("(%p, %d)\n", line
, wrap
);
1452 if(!line
|| wrap
== WrapModeClamp
)
1453 return InvalidParameter
;
1460 GpStatus WINGDIPAPI
GdipSetPathGradientBlend(GpPathGradient
*brush
, GDIPCONST REAL
*blend
,
1461 GDIPCONST REAL
*pos
, INT count
)
1465 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, pos
, count
);
1468 FIXME("not implemented\n");
1470 return NotImplemented
;
1473 GpStatus WINGDIPAPI
GdipSetPathGradientLinearBlend(GpPathGradient
*brush
,
1474 REAL focus
, REAL scale
)
1478 TRACE("(%p,%0.2f,%0.2f)\n", brush
, focus
, scale
);
1481 FIXME("not implemented\n");
1483 return NotImplemented
;
1486 GpStatus WINGDIPAPI
GdipSetPathGradientPresetBlend(GpPathGradient
*brush
,
1487 GDIPCONST ARGB
*blend
, GDIPCONST REAL
*pos
, INT count
)
1489 FIXME("(%p,%p,%p,%i): stub\n", brush
, blend
, pos
, count
);
1490 return NotImplemented
;
1493 GpStatus WINGDIPAPI
GdipGetPathGradientPresetBlend(GpPathGradient
*brush
,
1494 ARGB
*blend
, REAL
*pos
, INT count
)
1496 FIXME("(%p,%p,%p,%i): stub\n", brush
, blend
, pos
, count
);
1497 return NotImplemented
;
1500 GpStatus WINGDIPAPI
GdipGetPathGradientPresetBlendCount(GpPathGradient
*brush
,
1503 FIXME("(%p,%p): stub\n", brush
, count
);
1504 return NotImplemented
;
1507 GpStatus WINGDIPAPI
GdipSetPathGradientCenterColor(GpPathGradient
*grad
,
1510 TRACE("(%p, %x)\n", grad
, argb
);
1513 return InvalidParameter
;
1515 grad
->centercolor
= argb
;
1516 grad
->brush
.lb
.lbColor
= ARGB2COLORREF(argb
);
1518 DeleteObject(grad
->brush
.gdibrush
);
1519 grad
->brush
.gdibrush
= CreateSolidBrush(grad
->brush
.lb
.lbColor
);
1524 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPoint(GpPathGradient
*grad
,
1527 TRACE("(%p, %s)\n", grad
, debugstr_pointf(point
));
1530 return InvalidParameter
;
1532 grad
->center
.X
= point
->X
;
1533 grad
->center
.Y
= point
->Y
;
1538 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPointI(GpPathGradient
*grad
,
1543 TRACE("(%p, %p)\n", grad
, point
);
1546 return InvalidParameter
;
1548 ptf
.X
= (REAL
)point
->X
;
1549 ptf
.Y
= (REAL
)point
->Y
;
1551 return GdipSetPathGradientCenterPoint(grad
,&ptf
);
1554 GpStatus WINGDIPAPI
GdipSetPathGradientFocusScales(GpPathGradient
*grad
,
1557 TRACE("(%p, %.2f, %.2f)\n", grad
, x
, y
);
1560 return InvalidParameter
;
1568 GpStatus WINGDIPAPI
GdipSetPathGradientGammaCorrection(GpPathGradient
*grad
,
1571 TRACE("(%p, %d)\n", grad
, gamma
);
1574 return InvalidParameter
;
1576 grad
->gamma
= gamma
;
1581 GpStatus WINGDIPAPI
GdipSetPathGradientSigmaBlend(GpPathGradient
*grad
,
1582 REAL focus
, REAL scale
)
1586 TRACE("(%p,%0.2f,%0.2f)\n", grad
, focus
, scale
);
1588 if(!grad
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1589 return InvalidParameter
;
1592 FIXME("not implemented\n");
1594 return NotImplemented
;
1597 GpStatus WINGDIPAPI
GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1598 *grad
, GDIPCONST ARGB
*argb
, INT
*count
)
1602 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1604 if(!grad
|| !argb
|| !count
|| (*count
<= 0) ||
1605 (*count
> grad
->pathdata
.Count
))
1606 return InvalidParameter
;
1609 FIXME("not implemented\n");
1611 return NotImplemented
;
1614 GpStatus WINGDIPAPI
GdipSetPathGradientWrapMode(GpPathGradient
*grad
,
1617 TRACE("(%p, %d)\n", grad
, wrap
);
1620 return InvalidParameter
;
1627 GpStatus WINGDIPAPI
GdipSetPathGradientTransform(GpPathGradient
*grad
,
1632 TRACE("(%p,%p)\n", grad
, matrix
);
1635 FIXME("not implemented\n");
1637 return NotImplemented
;
1640 GpStatus WINGDIPAPI
GdipGetPathGradientTransform(GpPathGradient
*grad
,
1645 TRACE("(%p,%p)\n", grad
, matrix
);
1648 FIXME("not implemented\n");
1650 return NotImplemented
;
1653 GpStatus WINGDIPAPI
GdipMultiplyPathGradientTransform(GpPathGradient
*grad
,
1654 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1658 TRACE("(%p,%p,%i)\n", grad
, matrix
, order
);
1661 FIXME("not implemented\n");
1663 return NotImplemented
;
1666 GpStatus WINGDIPAPI
GdipRotatePathGradientTransform(GpPathGradient
*grad
,
1667 REAL angle
, GpMatrixOrder order
)
1671 TRACE("(%p,%0.2f,%i)\n", grad
, angle
, order
);
1674 FIXME("not implemented\n");
1676 return NotImplemented
;
1679 GpStatus WINGDIPAPI
GdipScalePathGradientTransform(GpPathGradient
*grad
,
1680 REAL sx
, REAL sy
, GpMatrixOrder order
)
1684 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad
, sx
, sy
, order
);
1687 FIXME("not implemented\n");
1689 return NotImplemented
;
1692 GpStatus WINGDIPAPI
GdipTranslatePathGradientTransform(GpPathGradient
*grad
,
1693 REAL dx
, REAL dy
, GpMatrixOrder order
)
1697 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad
, dx
, dy
, order
);
1700 FIXME("not implemented\n");
1702 return NotImplemented
;
1705 GpStatus WINGDIPAPI
GdipSetSolidFillColor(GpSolidFill
*sf
, ARGB argb
)
1707 TRACE("(%p, %x)\n", sf
, argb
);
1710 return InvalidParameter
;
1713 sf
->brush
.lb
.lbColor
= ARGB2COLORREF(argb
);
1715 DeleteObject(sf
->brush
.gdibrush
);
1716 sf
->brush
.gdibrush
= CreateSolidBrush(sf
->brush
.lb
.lbColor
);
1721 /******************************************************************************
1722 * GdipSetTextureTransform [GDIPLUS.@]
1724 GpStatus WINGDIPAPI
GdipSetTextureTransform(GpTexture
*texture
,
1725 GDIPCONST GpMatrix
*matrix
)
1727 TRACE("(%p, %p)\n", texture
, matrix
);
1729 if(!texture
|| !matrix
)
1730 return InvalidParameter
;
1732 memcpy(texture
->transform
, matrix
, sizeof(GpMatrix
));
1737 /******************************************************************************
1738 * GdipSetTextureWrapMode [GDIPLUS.@]
1740 * WrapMode not used, only stored
1742 GpStatus WINGDIPAPI
GdipSetTextureWrapMode(GpTexture
*brush
, GpWrapMode wrapmode
)
1744 TRACE("(%p, %d)\n", brush
, wrapmode
);
1747 return InvalidParameter
;
1749 brush
->wrap
= wrapmode
;
1754 GpStatus WINGDIPAPI
GdipSetLineColors(GpLineGradient
*brush
, ARGB color1
,
1757 TRACE("(%p, %x, %x)\n", brush
, color1
, color2
);
1760 return InvalidParameter
;
1762 brush
->startcolor
= color1
;
1763 brush
->endcolor
= color2
;
1768 GpStatus WINGDIPAPI
GdipGetLineColors(GpLineGradient
*brush
, ARGB
*colors
)
1770 TRACE("(%p, %p)\n", brush
, colors
);
1772 if(!brush
|| !colors
)
1773 return InvalidParameter
;
1775 colors
[0] = brush
->startcolor
;
1776 colors
[1] = brush
->endcolor
;
1781 /******************************************************************************
1782 * GdipRotateTextureTransform [GDIPLUS.@]
1784 GpStatus WINGDIPAPI
GdipRotateTextureTransform(GpTexture
* brush
, REAL angle
,
1785 GpMatrixOrder order
)
1787 TRACE("(%p, %.2f, %d)\n", brush
, angle
, order
);
1790 return InvalidParameter
;
1792 return GdipRotateMatrix(brush
->transform
, angle
, order
);
1795 GpStatus WINGDIPAPI
GdipSetLineLinearBlend(GpLineGradient
*brush
, REAL focus
,
1802 TRACE("(%p,%.2f,%.2f)\n", brush
, focus
, scale
);
1804 if (!brush
) return InvalidParameter
;
1808 factors
[num_points
] = 0.0;
1809 positions
[num_points
] = 0.0;
1813 factors
[num_points
] = scale
;
1814 positions
[num_points
] = focus
;
1819 factors
[num_points
] = 0.0;
1820 positions
[num_points
] = 1.0;
1824 return GdipSetLineBlend(brush
, factors
, positions
, num_points
);
1827 GpStatus WINGDIPAPI
GdipSetLinePresetBlend(GpLineGradient
*brush
,
1828 GDIPCONST ARGB
*blend
, GDIPCONST REAL
* positions
, INT count
)
1832 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, positions
, count
);
1834 if (!brush
|| !blend
|| !positions
|| count
< 2 ||
1835 positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)
1837 return InvalidParameter
;
1840 new_color
= GdipAlloc(count
* sizeof(ARGB
));
1841 new_pos
= GdipAlloc(count
* sizeof(REAL
));
1842 if (!new_color
|| !new_pos
)
1844 GdipFree(new_color
);
1849 memcpy(new_color
, blend
, sizeof(ARGB
) * count
);
1850 memcpy(new_pos
, positions
, sizeof(REAL
) * count
);
1852 GdipFree(brush
->pblendcolor
);
1853 GdipFree(brush
->pblendpos
);
1855 brush
->pblendcolor
= new_color
;
1856 brush
->pblendpos
= new_pos
;
1857 brush
->pblendcount
= count
;
1862 GpStatus WINGDIPAPI
GdipGetLinePresetBlend(GpLineGradient
*brush
,
1863 ARGB
*blend
, REAL
* positions
, INT count
)
1865 if (!brush
|| !blend
|| !positions
|| count
< 2)
1866 return InvalidParameter
;
1868 if (brush
->pblendcount
== 0)
1869 return GenericError
;
1871 if (count
< brush
->pblendcount
)
1872 return InsufficientBuffer
;
1874 memcpy(blend
, brush
->pblendcolor
, sizeof(ARGB
) * brush
->pblendcount
);
1875 memcpy(positions
, brush
->pblendpos
, sizeof(REAL
) * brush
->pblendcount
);
1880 GpStatus WINGDIPAPI
GdipGetLinePresetBlendCount(GpLineGradient
*brush
,
1883 if (!brush
|| !count
)
1884 return InvalidParameter
;
1886 *count
= brush
->pblendcount
;
1891 GpStatus WINGDIPAPI
GdipResetLineTransform(GpLineGradient
*brush
)
1895 TRACE("(%p)\n", brush
);
1898 FIXME("not implemented\n");
1900 return NotImplemented
;
1903 GpStatus WINGDIPAPI
GdipSetLineTransform(GpLineGradient
*brush
,
1904 GDIPCONST GpMatrix
*matrix
)
1908 TRACE("(%p,%p)\n", brush
, matrix
);
1911 FIXME("not implemented\n");
1913 return NotImplemented
;
1916 GpStatus WINGDIPAPI
GdipGetLineTransform(GpLineGradient
*brush
, GpMatrix
*matrix
)
1920 TRACE("(%p,%p)\n", brush
, matrix
);
1923 FIXME("not implemented\n");
1925 return NotImplemented
;
1928 GpStatus WINGDIPAPI
GdipScaleLineTransform(GpLineGradient
*brush
, REAL sx
, REAL sy
,
1929 GpMatrixOrder order
)
1933 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush
, sx
, sy
, order
);
1936 FIXME("not implemented\n");
1938 return NotImplemented
;
1941 GpStatus WINGDIPAPI
GdipMultiplyLineTransform(GpLineGradient
*brush
,
1942 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1946 TRACE("(%p,%p,%u)\n", brush
, matrix
, order
);
1949 FIXME("not implemented\n");
1951 return NotImplemented
;
1954 GpStatus WINGDIPAPI
GdipTranslateLineTransform(GpLineGradient
* brush
,
1955 REAL dx
, REAL dy
, GpMatrixOrder order
)
1957 FIXME("stub: %p %f %f %d\n", brush
, dx
, dy
, order
);
1959 return NotImplemented
;
1962 /******************************************************************************
1963 * GdipTranslateTextureTransform [GDIPLUS.@]
1965 GpStatus WINGDIPAPI
GdipTranslateTextureTransform(GpTexture
* brush
, REAL dx
, REAL dy
,
1966 GpMatrixOrder order
)
1968 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, dx
, dy
, order
);
1971 return InvalidParameter
;
1973 return GdipTranslateMatrix(brush
->transform
, dx
, dy
, order
);
1976 GpStatus WINGDIPAPI
GdipGetLineRect(GpLineGradient
*brush
, GpRectF
*rect
)
1978 TRACE("(%p, %p)\n", brush
, rect
);
1981 return InvalidParameter
;
1983 *rect
= brush
->rect
;
1988 GpStatus WINGDIPAPI
GdipGetLineRectI(GpLineGradient
*brush
, GpRect
*rect
)
1993 TRACE("(%p, %p)\n", brush
, rect
);
1996 return InvalidParameter
;
1998 ret
= GdipGetLineRect(brush
, &rectF
);
2001 rect
->X
= roundr(rectF
.X
);
2002 rect
->Y
= roundr(rectF
.Y
);
2003 rect
->Width
= roundr(rectF
.Width
);
2004 rect
->Height
= roundr(rectF
.Height
);
2010 GpStatus WINGDIPAPI
GdipRotateLineTransform(GpLineGradient
* brush
,
2011 REAL angle
, GpMatrixOrder order
)
2015 TRACE("(%p,%0.2f,%u)\n", brush
, angle
, order
);
2018 return InvalidParameter
;
2021 FIXME("(%p, %.2f, %d) stub\n", brush
, angle
, order
);
2023 return NotImplemented
;