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
:
50 *clone
= GdipAlloc(sizeof(GpSolidFill
));
51 if (!*clone
) return OutOfMemory
;
52 memcpy(*clone
, brush
, sizeof(GpSolidFill
));
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
;
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
);
81 stat
= GdipCloneMatrix(src
->transform
, &dest
->transform
);
84 GdipDeletePath(dest
->path
);
90 count
= src
->blendcount
;
91 dest
->blendcount
= count
;
92 dest
->blendfac
= GdipAlloc(count
* sizeof(REAL
));
93 dest
->blendpos
= GdipAlloc(count
* sizeof(REAL
));
94 dest
->surroundcolors
= GdipAlloc(dest
->surroundcolorcount
* sizeof(ARGB
));
95 pcount
= dest
->pblendcount
;
98 dest
->pblendcolor
= GdipAlloc(pcount
* sizeof(ARGB
));
99 dest
->pblendpos
= GdipAlloc(pcount
* sizeof(REAL
));
102 if(!dest
->blendfac
|| !dest
->blendpos
|| !dest
->surroundcolors
||
103 (pcount
&& (!dest
->pblendcolor
|| !dest
->pblendpos
))){
104 GdipDeletePath(dest
->path
);
105 GdipDeleteMatrix(dest
->transform
);
106 GdipFree(dest
->blendfac
);
107 GdipFree(dest
->blendpos
);
108 GdipFree(dest
->surroundcolors
);
109 GdipFree(dest
->pblendcolor
);
110 GdipFree(dest
->pblendpos
);
115 memcpy(dest
->blendfac
, src
->blendfac
, count
* sizeof(REAL
));
116 memcpy(dest
->blendpos
, src
->blendpos
, count
* sizeof(REAL
));
117 memcpy(dest
->surroundcolors
, src
->surroundcolors
, dest
->surroundcolorcount
* sizeof(ARGB
));
121 memcpy(dest
->pblendcolor
, src
->pblendcolor
, pcount
* sizeof(ARGB
));
122 memcpy(dest
->pblendpos
, src
->pblendpos
, pcount
* sizeof(REAL
));
127 case BrushTypeLinearGradient
:{
128 GpLineGradient
*dest
, *src
;
131 dest
= GdipAlloc(sizeof(GpLineGradient
));
132 if(!dest
) return OutOfMemory
;
134 src
= (GpLineGradient
*)brush
;
136 memcpy(dest
, src
, sizeof(GpLineGradient
));
138 count
= dest
->blendcount
;
139 dest
->blendfac
= GdipAlloc(count
* sizeof(REAL
));
140 dest
->blendpos
= GdipAlloc(count
* sizeof(REAL
));
141 pcount
= dest
->pblendcount
;
144 dest
->pblendcolor
= GdipAlloc(pcount
* sizeof(ARGB
));
145 dest
->pblendpos
= GdipAlloc(pcount
* sizeof(REAL
));
148 if (!dest
->blendfac
|| !dest
->blendpos
||
149 (pcount
&& (!dest
->pblendcolor
|| !dest
->pblendpos
)))
151 GdipFree(dest
->blendfac
);
152 GdipFree(dest
->blendpos
);
153 GdipFree(dest
->pblendcolor
);
154 GdipFree(dest
->pblendpos
);
159 memcpy(dest
->blendfac
, src
->blendfac
, count
* sizeof(REAL
));
160 memcpy(dest
->blendpos
, src
->blendpos
, count
* sizeof(REAL
));
164 memcpy(dest
->pblendcolor
, src
->pblendcolor
, pcount
* sizeof(ARGB
));
165 memcpy(dest
->pblendpos
, src
->pblendpos
, pcount
* sizeof(REAL
));
168 *clone
= &dest
->brush
;
171 case BrushTypeTextureFill
:
174 GpTexture
*texture
= (GpTexture
*)brush
;
175 GpTexture
*new_texture
;
178 stat
= GdipGetImageWidth(texture
->image
, &width
);
179 if (stat
!= Ok
) return stat
;
180 stat
= GdipGetImageHeight(texture
->image
, &height
);
181 if (stat
!= Ok
) return stat
;
183 stat
= GdipCreateTextureIA(texture
->image
, texture
->imageattributes
, 0, 0, width
, height
, &new_texture
);
187 memcpy(new_texture
->transform
, texture
->transform
, sizeof(GpMatrix
));
188 *clone
= (GpBrush
*)new_texture
;
196 ERR("not implemented for brush type %d\n", brush
->bt
);
197 return NotImplemented
;
200 TRACE("<-- %p\n", *clone
);
204 static const char HatchBrushes
[][8] = {
205 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
206 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
207 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
208 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
209 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
210 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
211 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
212 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
213 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
214 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
215 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
216 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
217 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
218 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
219 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
220 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
221 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
222 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
223 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
224 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
225 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
226 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
227 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
228 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
229 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
230 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
231 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
232 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
233 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
234 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
237 GpStatus
get_hatch_data(HatchStyle hatchstyle
, const char **result
)
239 if (hatchstyle
< sizeof(HatchBrushes
) / sizeof(HatchBrushes
[0]))
241 *result
= HatchBrushes
[hatchstyle
];
245 return NotImplemented
;
248 /******************************************************************************
249 * GdipCreateHatchBrush [GDIPLUS.@]
251 GpStatus WINGDIPAPI
GdipCreateHatchBrush(HatchStyle hatchstyle
, ARGB forecol
, ARGB backcol
, GpHatch
**brush
)
253 TRACE("(%d, %d, %d, %p)\n", hatchstyle
, forecol
, backcol
, brush
);
255 if(!brush
) return InvalidParameter
;
257 *brush
= GdipAlloc(sizeof(GpHatch
));
258 if (!*brush
) return OutOfMemory
;
260 (*brush
)->brush
.bt
= BrushTypeHatchFill
;
261 (*brush
)->forecol
= forecol
;
262 (*brush
)->backcol
= backcol
;
263 (*brush
)->hatchstyle
= hatchstyle
;
264 TRACE("<-- %p\n", *brush
);
269 /******************************************************************************
270 * GdipCreateLineBrush [GDIPLUS.@]
272 GpStatus WINGDIPAPI
GdipCreateLineBrush(GDIPCONST GpPointF
* startpoint
,
273 GDIPCONST GpPointF
* endpoint
, ARGB startcolor
, ARGB endcolor
,
274 GpWrapMode wrap
, GpLineGradient
**line
)
276 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint
),
277 debugstr_pointf(endpoint
), startcolor
, endcolor
, wrap
, line
);
279 if(!line
|| !startpoint
|| !endpoint
|| wrap
== WrapModeClamp
)
280 return InvalidParameter
;
282 if (startpoint
->X
== endpoint
->X
&& startpoint
->Y
== endpoint
->Y
)
285 *line
= GdipAlloc(sizeof(GpLineGradient
));
286 if(!*line
) return OutOfMemory
;
288 (*line
)->brush
.bt
= BrushTypeLinearGradient
;
290 (*line
)->startpoint
.X
= startpoint
->X
;
291 (*line
)->startpoint
.Y
= startpoint
->Y
;
292 (*line
)->endpoint
.X
= endpoint
->X
;
293 (*line
)->endpoint
.Y
= endpoint
->Y
;
294 (*line
)->startcolor
= startcolor
;
295 (*line
)->endcolor
= endcolor
;
296 (*line
)->wrap
= wrap
;
297 (*line
)->gamma
= FALSE
;
299 (*line
)->rect
.X
= (startpoint
->X
< endpoint
->X
? startpoint
->X
: endpoint
->X
);
300 (*line
)->rect
.Y
= (startpoint
->Y
< endpoint
->Y
? startpoint
->Y
: endpoint
->Y
);
301 (*line
)->rect
.Width
= fabs(startpoint
->X
- endpoint
->X
);
302 (*line
)->rect
.Height
= fabs(startpoint
->Y
- endpoint
->Y
);
304 if ((*line
)->rect
.Width
== 0)
306 (*line
)->rect
.X
-= (*line
)->rect
.Height
/ 2.0f
;
307 (*line
)->rect
.Width
= (*line
)->rect
.Height
;
309 else if ((*line
)->rect
.Height
== 0)
311 (*line
)->rect
.Y
-= (*line
)->rect
.Width
/ 2.0f
;
312 (*line
)->rect
.Height
= (*line
)->rect
.Width
;
315 (*line
)->blendcount
= 1;
316 (*line
)->blendfac
= GdipAlloc(sizeof(REAL
));
317 (*line
)->blendpos
= GdipAlloc(sizeof(REAL
));
319 if (!(*line
)->blendfac
|| !(*line
)->blendpos
)
321 GdipFree((*line
)->blendfac
);
322 GdipFree((*line
)->blendpos
);
328 (*line
)->blendfac
[0] = 1.0f
;
329 (*line
)->blendpos
[0] = 1.0f
;
331 (*line
)->pblendcolor
= NULL
;
332 (*line
)->pblendpos
= NULL
;
333 (*line
)->pblendcount
= 0;
335 TRACE("<-- %p\n", *line
);
340 GpStatus WINGDIPAPI
GdipCreateLineBrushI(GDIPCONST GpPoint
* startpoint
,
341 GDIPCONST GpPoint
* endpoint
, ARGB startcolor
, ARGB endcolor
,
342 GpWrapMode wrap
, GpLineGradient
**line
)
347 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint
, endpoint
,
348 startcolor
, endcolor
, wrap
, line
);
350 if(!startpoint
|| !endpoint
)
351 return InvalidParameter
;
353 stF
.X
= (REAL
)startpoint
->X
;
354 stF
.Y
= (REAL
)startpoint
->Y
;
355 endF
.X
= (REAL
)endpoint
->X
;
356 endF
.Y
= (REAL
)endpoint
->Y
;
358 return GdipCreateLineBrush(&stF
, &endF
, startcolor
, endcolor
, wrap
, line
);
361 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRect(GDIPCONST GpRectF
* rect
,
362 ARGB startcolor
, ARGB endcolor
, LinearGradientMode mode
, GpWrapMode wrap
,
363 GpLineGradient
**line
)
368 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect
, startcolor
, endcolor
, mode
,
372 return InvalidParameter
;
376 case LinearGradientModeHorizontal
:
379 end
.X
= rect
->X
+ rect
->Width
;
382 case LinearGradientModeVertical
:
386 end
.Y
= rect
->Y
+ rect
->Height
;
388 case LinearGradientModeForwardDiagonal
:
391 end
.X
= rect
->X
+ rect
->Width
;
392 end
.Y
= rect
->Y
+ rect
->Height
;
394 case LinearGradientModeBackwardDiagonal
:
395 start
.X
= rect
->X
+ rect
->Width
;
398 end
.Y
= rect
->Y
+ rect
->Height
;
401 return InvalidParameter
;
404 stat
= GdipCreateLineBrush(&start
, &end
, startcolor
, endcolor
, wrap
, line
);
407 (*line
)->rect
= *rect
;
412 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectI(GDIPCONST GpRect
* rect
,
413 ARGB startcolor
, ARGB endcolor
, LinearGradientMode mode
, GpWrapMode wrap
,
414 GpLineGradient
**line
)
418 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect
, startcolor
, endcolor
, mode
,
421 rectF
.X
= (REAL
) rect
->X
;
422 rectF
.Y
= (REAL
) rect
->Y
;
423 rectF
.Width
= (REAL
) rect
->Width
;
424 rectF
.Height
= (REAL
) rect
->Height
;
426 return GdipCreateLineBrushFromRect(&rectF
, startcolor
, endcolor
, mode
, wrap
, line
);
429 /******************************************************************************
430 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
432 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF
* rect
,
433 ARGB startcolor
, ARGB endcolor
, REAL angle
, BOOL isAngleScalable
, GpWrapMode wrap
,
434 GpLineGradient
**line
)
437 LinearGradientMode mode
;
438 REAL width
, height
, exofs
, eyofs
;
439 REAL sin_angle
, cos_angle
, sin_cos_angle
;
441 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect
, startcolor
, endcolor
, angle
, isAngleScalable
,
444 sin_angle
= sinf(deg2rad(angle
));
445 cos_angle
= cosf(deg2rad(angle
));
446 sin_cos_angle
= sin_angle
* cos_angle
;
450 width
= height
= 1.0;
455 height
= rect
->Height
;
458 if (sin_cos_angle
>= 0)
459 mode
= LinearGradientModeForwardDiagonal
;
461 mode
= LinearGradientModeBackwardDiagonal
;
463 stat
= GdipCreateLineBrushFromRect(rect
, startcolor
, endcolor
, mode
, wrap
, line
);
467 if (sin_cos_angle
>= 0)
469 exofs
= width
* sin_cos_angle
+ height
* cos_angle
* cos_angle
;
470 eyofs
= width
* sin_angle
* sin_angle
+ height
* sin_cos_angle
;
474 exofs
= width
* sin_angle
* sin_angle
+ height
* sin_cos_angle
;
475 eyofs
= -width
* sin_cos_angle
+ height
* sin_angle
* sin_angle
;
480 exofs
= exofs
* rect
->Width
;
481 eyofs
= eyofs
* rect
->Height
;
486 (*line
)->endpoint
.X
= rect
->X
+ exofs
;
487 (*line
)->endpoint
.Y
= rect
->Y
+ eyofs
;
491 (*line
)->endpoint
.X
= (*line
)->startpoint
.X
;
492 (*line
)->endpoint
.Y
= (*line
)->startpoint
.Y
;
493 (*line
)->startpoint
.X
= rect
->X
+ exofs
;
494 (*line
)->startpoint
.Y
= rect
->Y
+ eyofs
;
501 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect
* rect
,
502 ARGB startcolor
, ARGB endcolor
, REAL angle
, BOOL isAngleScalable
, GpWrapMode wrap
,
503 GpLineGradient
**line
)
505 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect
, startcolor
, endcolor
, angle
, isAngleScalable
,
508 return GdipCreateLineBrushFromRectI(rect
, startcolor
, endcolor
, LinearGradientModeForwardDiagonal
,
512 static GpStatus
create_path_gradient(GpPath
*path
, ARGB centercolor
, GpPathGradient
**grad
)
518 return InvalidParameter
;
520 if (path
->pathdata
.Count
< 2)
523 GdipGetPathWorldBounds(path
, &bounds
, NULL
, NULL
);
525 *grad
= GdipAlloc(sizeof(GpPathGradient
));
531 stat
= GdipCreateMatrix(&(*grad
)->transform
);
538 (*grad
)->blendfac
= GdipAlloc(sizeof(REAL
));
539 (*grad
)->blendpos
= GdipAlloc(sizeof(REAL
));
540 (*grad
)->surroundcolors
= GdipAlloc(sizeof(ARGB
));
541 if(!(*grad
)->blendfac
|| !(*grad
)->blendpos
|| !(*grad
)->surroundcolors
){
542 GdipDeleteMatrix((*grad
)->transform
);
543 GdipFree((*grad
)->blendfac
);
544 GdipFree((*grad
)->blendpos
);
545 GdipFree((*grad
)->surroundcolors
);
550 (*grad
)->blendfac
[0] = 1.0;
551 (*grad
)->blendpos
[0] = 1.0;
552 (*grad
)->blendcount
= 1;
554 (*grad
)->path
= path
;
556 (*grad
)->brush
.bt
= BrushTypePathGradient
;
557 (*grad
)->centercolor
= centercolor
;
558 (*grad
)->wrap
= WrapModeClamp
;
559 (*grad
)->gamma
= FALSE
;
560 /* FIXME: this should be set to the "centroid" of the path by default */
561 (*grad
)->center
.X
= bounds
.X
+ bounds
.Width
/ 2;
562 (*grad
)->center
.Y
= bounds
.Y
+ bounds
.Height
/ 2;
563 (*grad
)->focus
.X
= 0.0;
564 (*grad
)->focus
.Y
= 0.0;
565 (*grad
)->surroundcolors
[0] = 0xffffffff;
566 (*grad
)->surroundcolorcount
= 1;
568 TRACE("<-- %p\n", *grad
);
573 GpStatus WINGDIPAPI
GdipCreatePathGradient(GDIPCONST GpPointF
* points
,
574 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
579 TRACE("(%p, %d, %d, %p)\n", points
, count
, wrap
, grad
);
582 return InvalidParameter
;
587 stat
= GdipCreatePath(FillModeAlternate
, &path
);
591 stat
= GdipAddPathLine2(path
, points
, count
);
594 stat
= create_path_gradient(path
, 0xff000000, grad
);
597 GdipDeletePath(path
);
603 GpStatus WINGDIPAPI
GdipCreatePathGradientI(GDIPCONST GpPoint
* points
,
604 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
609 TRACE("(%p, %d, %d, %p)\n", points
, count
, wrap
, grad
);
612 return InvalidParameter
;
617 stat
= GdipCreatePath(FillModeAlternate
, &path
);
621 stat
= GdipAddPathLine2I(path
, points
, count
);
624 stat
= create_path_gradient(path
, 0xff000000, grad
);
627 GdipDeletePath(path
);
633 /******************************************************************************
634 * GdipCreatePathGradientFromPath [GDIPLUS.@]
636 GpStatus WINGDIPAPI
GdipCreatePathGradientFromPath(GDIPCONST GpPath
* path
,
637 GpPathGradient
**grad
)
642 TRACE("(%p, %p)\n", path
, grad
);
645 return InvalidParameter
;
647 stat
= GdipClonePath((GpPath
*)path
, &new_path
);
651 stat
= create_path_gradient(new_path
, 0xffffffff, grad
);
654 GdipDeletePath(new_path
);
660 /******************************************************************************
661 * GdipCreateSolidFill [GDIPLUS.@]
663 GpStatus WINGDIPAPI
GdipCreateSolidFill(ARGB color
, GpSolidFill
**sf
)
665 TRACE("(%x, %p)\n", color
, sf
);
667 if(!sf
) return InvalidParameter
;
669 *sf
= GdipAlloc(sizeof(GpSolidFill
));
670 if (!*sf
) return OutOfMemory
;
672 (*sf
)->brush
.bt
= BrushTypeSolidColor
;
673 (*sf
)->color
= color
;
675 TRACE("<-- %p\n", *sf
);
680 /******************************************************************************
681 * GdipCreateTexture [GDIPLUS.@]
684 * image [I] image to use
685 * wrapmode [I] optional
686 * texture [O] pointer to the resulting texturebrush
690 * FAILURE: element of GpStatus
692 GpStatus WINGDIPAPI
GdipCreateTexture(GpImage
*image
, GpWrapMode wrapmode
,
696 GpImageAttributes
*attributes
;
699 TRACE("%p, %d %p\n", image
, wrapmode
, texture
);
701 if (!(image
&& texture
))
702 return InvalidParameter
;
704 stat
= GdipGetImageWidth(image
, &width
);
705 if (stat
!= Ok
) return stat
;
706 stat
= GdipGetImageHeight(image
, &height
);
707 if (stat
!= Ok
) return stat
;
709 stat
= GdipCreateImageAttributes(&attributes
);
713 attributes
->wrap
= wrapmode
;
715 stat
= GdipCreateTextureIA(image
, attributes
, 0, 0, width
, height
,
718 GdipDisposeImageAttributes(attributes
);
724 /******************************************************************************
725 * GdipCreateTexture2 [GDIPLUS.@]
727 GpStatus WINGDIPAPI
GdipCreateTexture2(GpImage
*image
, GpWrapMode wrapmode
,
728 REAL x
, REAL y
, REAL width
, REAL height
, GpTexture
**texture
)
730 GpImageAttributes
*attributes
;
733 TRACE("%p %d %f %f %f %f %p\n", image
, wrapmode
,
734 x
, y
, width
, height
, texture
);
736 stat
= GdipCreateImageAttributes(&attributes
);
740 attributes
->wrap
= wrapmode
;
742 stat
= GdipCreateTextureIA(image
, attributes
, x
, y
, width
, height
,
745 GdipDisposeImageAttributes(attributes
);
751 /******************************************************************************
752 * GdipCreateTextureIA [GDIPLUS.@]
754 * FIXME: imageattr ignored
756 GpStatus WINGDIPAPI
GdipCreateTextureIA(GpImage
*image
,
757 GDIPCONST GpImageAttributes
*imageattr
, REAL x
, REAL y
, REAL width
,
758 REAL height
, GpTexture
**texture
)
761 GpImage
*new_image
=NULL
;
763 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image
, imageattr
, x
, y
, width
, height
,
766 if(!image
|| !texture
|| x
< 0.0 || y
< 0.0 || width
< 0.0 || height
< 0.0)
767 return InvalidParameter
;
771 if(image
->type
!= ImageTypeBitmap
){
772 FIXME("not implemented for image type %d\n", image
->type
);
773 return NotImplemented
;
776 status
= GdipCloneBitmapArea(x
, y
, width
, height
, PixelFormatDontCare
, (GpBitmap
*)image
, (GpBitmap
**)&new_image
);
780 *texture
= GdipAlloc(sizeof(GpTexture
));
782 status
= OutOfMemory
;
786 if((status
= GdipCreateMatrix(&(*texture
)->transform
)) != Ok
){
792 status
= GdipCloneImageAttributes(imageattr
, &(*texture
)->imageattributes
);
796 status
= GdipCreateImageAttributes(&(*texture
)->imageattributes
);
798 (*texture
)->imageattributes
->wrap
= WrapModeTile
;
802 (*texture
)->brush
.bt
= BrushTypeTextureFill
;
803 (*texture
)->image
= new_image
;
809 TRACE("<-- %p\n", *texture
);
815 GdipDeleteMatrix((*texture
)->transform
);
816 GdipDisposeImageAttributes((*texture
)->imageattributes
);
820 GdipDisposeImage(new_image
);
821 TRACE("<-- error %u\n", status
);
827 /******************************************************************************
828 * GdipCreateTextureIAI [GDIPLUS.@]
830 GpStatus WINGDIPAPI
GdipCreateTextureIAI(GpImage
*image
, GDIPCONST GpImageAttributes
*imageattr
,
831 INT x
, INT y
, INT width
, INT height
, GpTexture
**texture
)
833 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image
, imageattr
, x
, y
, width
, height
,
836 return GdipCreateTextureIA(image
,imageattr
,(REAL
)x
,(REAL
)y
,(REAL
)width
,(REAL
)height
,texture
);
839 GpStatus WINGDIPAPI
GdipCreateTexture2I(GpImage
*image
, GpWrapMode wrapmode
,
840 INT x
, INT y
, INT width
, INT height
, GpTexture
**texture
)
842 GpImageAttributes
*imageattr
;
845 TRACE("%p %d %d %d %d %d %p\n", image
, wrapmode
, x
, y
, width
, height
,
848 stat
= GdipCreateImageAttributes(&imageattr
);
852 imageattr
->wrap
= wrapmode
;
854 stat
= GdipCreateTextureIA(image
, imageattr
, x
, y
, width
, height
, texture
);
860 GpStatus WINGDIPAPI
GdipGetBrushType(GpBrush
*brush
, GpBrushType
*type
)
862 TRACE("(%p, %p)\n", brush
, type
);
864 if(!brush
|| !type
) return InvalidParameter
;
871 GpStatus WINGDIPAPI
GdipGetHatchBackgroundColor(GpHatch
*brush
, ARGB
*backcol
)
873 TRACE("(%p, %p)\n", brush
, backcol
);
875 if(!brush
|| !backcol
) return InvalidParameter
;
877 *backcol
= brush
->backcol
;
882 GpStatus WINGDIPAPI
GdipGetHatchForegroundColor(GpHatch
*brush
, ARGB
*forecol
)
884 TRACE("(%p, %p)\n", brush
, forecol
);
886 if(!brush
|| !forecol
) return InvalidParameter
;
888 *forecol
= brush
->forecol
;
893 GpStatus WINGDIPAPI
GdipGetHatchStyle(GpHatch
*brush
, HatchStyle
*hatchstyle
)
895 TRACE("(%p, %p)\n", brush
, hatchstyle
);
897 if(!brush
|| !hatchstyle
) return InvalidParameter
;
899 *hatchstyle
= brush
->hatchstyle
;
904 GpStatus WINGDIPAPI
GdipDeleteBrush(GpBrush
*brush
)
906 TRACE("(%p)\n", brush
);
908 if(!brush
) return InvalidParameter
;
912 case BrushTypePathGradient
:
913 GdipDeletePath(((GpPathGradient
*) brush
)->path
);
914 GdipDeleteMatrix(((GpPathGradient
*) brush
)->transform
);
915 GdipFree(((GpPathGradient
*) brush
)->blendfac
);
916 GdipFree(((GpPathGradient
*) brush
)->blendpos
);
917 GdipFree(((GpPathGradient
*) brush
)->surroundcolors
);
918 GdipFree(((GpPathGradient
*) brush
)->pblendcolor
);
919 GdipFree(((GpPathGradient
*) brush
)->pblendpos
);
921 case BrushTypeLinearGradient
:
922 GdipFree(((GpLineGradient
*)brush
)->blendfac
);
923 GdipFree(((GpLineGradient
*)brush
)->blendpos
);
924 GdipFree(((GpLineGradient
*)brush
)->pblendcolor
);
925 GdipFree(((GpLineGradient
*)brush
)->pblendpos
);
927 case BrushTypeTextureFill
:
928 GdipDeleteMatrix(((GpTexture
*)brush
)->transform
);
929 GdipDisposeImage(((GpTexture
*)brush
)->image
);
930 GdipDisposeImageAttributes(((GpTexture
*)brush
)->imageattributes
);
931 GdipFree(((GpTexture
*)brush
)->bitmap_bits
);
942 GpStatus WINGDIPAPI
GdipGetLineGammaCorrection(GpLineGradient
*line
,
945 TRACE("(%p, %p)\n", line
, usinggamma
);
947 if(!line
|| !usinggamma
)
948 return InvalidParameter
;
950 *usinggamma
= line
->gamma
;
955 GpStatus WINGDIPAPI
GdipGetLineWrapMode(GpLineGradient
*brush
, GpWrapMode
*wrapmode
)
957 TRACE("(%p, %p)\n", brush
, wrapmode
);
959 if(!brush
|| !wrapmode
)
960 return InvalidParameter
;
962 *wrapmode
= brush
->wrap
;
967 GpStatus WINGDIPAPI
GdipGetPathGradientBlend(GpPathGradient
*brush
, REAL
*blend
,
968 REAL
*positions
, INT count
)
970 TRACE("(%p, %p, %p, %d)\n", brush
, blend
, positions
, count
);
972 if(!brush
|| !blend
|| !positions
|| count
<= 0)
973 return InvalidParameter
;
975 if(count
< brush
->blendcount
)
976 return InsufficientBuffer
;
978 memcpy(blend
, brush
->blendfac
, count
*sizeof(REAL
));
979 if(brush
->blendcount
> 1){
980 memcpy(positions
, brush
->blendpos
, count
*sizeof(REAL
));
986 GpStatus WINGDIPAPI
GdipGetPathGradientBlendCount(GpPathGradient
*brush
, INT
*count
)
988 TRACE("(%p, %p)\n", brush
, count
);
991 return InvalidParameter
;
993 *count
= brush
->blendcount
;
998 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPoint(GpPathGradient
*grad
,
1001 TRACE("(%p, %p)\n", grad
, point
);
1004 return InvalidParameter
;
1006 point
->X
= grad
->center
.X
;
1007 point
->Y
= grad
->center
.Y
;
1012 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPointI(GpPathGradient
*grad
,
1018 TRACE("(%p, %p)\n", grad
, point
);
1021 return InvalidParameter
;
1023 ret
= GdipGetPathGradientCenterPoint(grad
,&ptf
);
1026 point
->X
= roundr(ptf
.X
);
1027 point
->Y
= roundr(ptf
.Y
);
1033 GpStatus WINGDIPAPI
GdipGetPathGradientCenterColor(GpPathGradient
*grad
,
1036 TRACE("(%p,%p)\n", grad
, colors
);
1038 if (!grad
|| !colors
)
1039 return InvalidParameter
;
1041 *colors
= grad
->centercolor
;
1046 GpStatus WINGDIPAPI
GdipGetPathGradientFocusScales(GpPathGradient
*grad
,
1049 TRACE("(%p, %p, %p)\n", grad
, x
, y
);
1051 if(!grad
|| !x
|| !y
)
1052 return InvalidParameter
;
1060 GpStatus WINGDIPAPI
GdipGetPathGradientGammaCorrection(GpPathGradient
*grad
,
1063 TRACE("(%p, %p)\n", grad
, gamma
);
1066 return InvalidParameter
;
1068 *gamma
= grad
->gamma
;
1073 GpStatus WINGDIPAPI
GdipGetPathGradientPath(GpPathGradient
*grad
, GpPath
*path
)
1077 TRACE("(%p, %p)\n", grad
, path
);
1080 FIXME("not implemented\n");
1082 return NotImplemented
;
1085 GpStatus WINGDIPAPI
GdipGetPathGradientPointCount(GpPathGradient
*grad
,
1088 TRACE("(%p, %p)\n", grad
, count
);
1091 return InvalidParameter
;
1093 *count
= grad
->path
->pathdata
.Count
;
1098 GpStatus WINGDIPAPI
GdipGetPathGradientRect(GpPathGradient
*brush
, GpRectF
*rect
)
1102 TRACE("(%p, %p)\n", brush
, rect
);
1105 return InvalidParameter
;
1107 stat
= GdipGetPathWorldBounds(brush
->path
, rect
, NULL
, NULL
);
1112 GpStatus WINGDIPAPI
GdipGetPathGradientRectI(GpPathGradient
*brush
, GpRect
*rect
)
1117 TRACE("(%p, %p)\n", brush
, rect
);
1120 return InvalidParameter
;
1122 stat
= GdipGetPathGradientRect(brush
, &rectf
);
1123 if(stat
!= Ok
) return stat
;
1125 rect
->X
= roundr(rectf
.X
);
1126 rect
->Y
= roundr(rectf
.Y
);
1127 rect
->Width
= roundr(rectf
.Width
);
1128 rect
->Height
= roundr(rectf
.Height
);
1133 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1134 *grad
, ARGB
*argb
, INT
*count
)
1138 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1140 if(!grad
|| !argb
|| !count
|| (*count
< grad
->path
->pathdata
.Count
))
1141 return InvalidParameter
;
1143 for (i
=0; i
<grad
->path
->pathdata
.Count
; i
++)
1145 if (i
< grad
->surroundcolorcount
)
1146 argb
[i
] = grad
->surroundcolors
[i
];
1148 argb
[i
] = grad
->surroundcolors
[grad
->surroundcolorcount
-1];
1151 *count
= grad
->surroundcolorcount
;
1156 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorCount(GpPathGradient
*brush
, INT
*count
)
1158 TRACE("(%p, %p)\n", brush
, count
);
1160 if (!brush
|| !count
)
1161 return InvalidParameter
;
1163 /* Yes, this actually returns the number of points in the path (which is the
1164 * required size of a buffer to get the surround colors), rather than the
1165 * number of surround colors. The real count is returned when getting the
1167 *count
= brush
->path
->pathdata
.Count
;
1172 GpStatus WINGDIPAPI
GdipGetPathGradientWrapMode(GpPathGradient
*brush
,
1173 GpWrapMode
*wrapmode
)
1175 TRACE("(%p, %p)\n", brush
, wrapmode
);
1177 if(!brush
|| !wrapmode
)
1178 return InvalidParameter
;
1180 *wrapmode
= brush
->wrap
;
1185 GpStatus WINGDIPAPI
GdipGetSolidFillColor(GpSolidFill
*sf
, ARGB
*argb
)
1187 TRACE("(%p, %p)\n", sf
, argb
);
1190 return InvalidParameter
;
1197 /******************************************************************************
1198 * GdipGetTextureImage [GDIPLUS.@]
1200 GpStatus WINGDIPAPI
GdipGetTextureImage(GpTexture
*brush
, GpImage
**image
)
1202 TRACE("(%p, %p)\n", brush
, image
);
1204 if(!brush
|| !image
)
1205 return InvalidParameter
;
1207 return GdipCloneImage(brush
->image
, image
);
1210 /******************************************************************************
1211 * GdipGetTextureTransform [GDIPLUS.@]
1213 GpStatus WINGDIPAPI
GdipGetTextureTransform(GpTexture
*brush
, GpMatrix
*matrix
)
1215 TRACE("(%p, %p)\n", brush
, matrix
);
1217 if(!brush
|| !matrix
)
1218 return InvalidParameter
;
1220 memcpy(matrix
, brush
->transform
, sizeof(GpMatrix
));
1225 /******************************************************************************
1226 * GdipGetTextureWrapMode [GDIPLUS.@]
1228 GpStatus WINGDIPAPI
GdipGetTextureWrapMode(GpTexture
*brush
, GpWrapMode
*wrapmode
)
1230 TRACE("(%p, %p)\n", brush
, wrapmode
);
1232 if(!brush
|| !wrapmode
)
1233 return InvalidParameter
;
1235 *wrapmode
= brush
->imageattributes
->wrap
;
1240 /******************************************************************************
1241 * GdipMultiplyTextureTransform [GDIPLUS.@]
1243 GpStatus WINGDIPAPI
GdipMultiplyTextureTransform(GpTexture
* brush
,
1244 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1246 TRACE("(%p, %p, %d)\n", brush
, matrix
, order
);
1248 if(!brush
|| !matrix
)
1249 return InvalidParameter
;
1251 return GdipMultiplyMatrix(brush
->transform
, matrix
, order
);
1254 /******************************************************************************
1255 * GdipResetTextureTransform [GDIPLUS.@]
1257 GpStatus WINGDIPAPI
GdipResetTextureTransform(GpTexture
* brush
)
1259 TRACE("(%p)\n", brush
);
1262 return InvalidParameter
;
1264 return GdipSetMatrixElements(brush
->transform
, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1267 /******************************************************************************
1268 * GdipScaleTextureTransform [GDIPLUS.@]
1270 GpStatus WINGDIPAPI
GdipScaleTextureTransform(GpTexture
* brush
,
1271 REAL sx
, REAL sy
, GpMatrixOrder order
)
1273 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, sx
, sy
, order
);
1276 return InvalidParameter
;
1278 return GdipScaleMatrix(brush
->transform
, sx
, sy
, order
);
1281 GpStatus WINGDIPAPI
GdipSetLineBlend(GpLineGradient
*brush
,
1282 GDIPCONST REAL
*factors
, GDIPCONST REAL
* positions
, INT count
)
1284 REAL
*new_blendfac
, *new_blendpos
;
1286 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1288 if(!brush
|| !factors
|| !positions
|| count
<= 0 ||
1289 (count
>= 2 && (positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)))
1290 return InvalidParameter
;
1292 new_blendfac
= GdipAlloc(count
* sizeof(REAL
));
1293 new_blendpos
= GdipAlloc(count
* sizeof(REAL
));
1295 if (!new_blendfac
|| !new_blendpos
)
1297 GdipFree(new_blendfac
);
1298 GdipFree(new_blendpos
);
1302 memcpy(new_blendfac
, factors
, count
* sizeof(REAL
));
1303 memcpy(new_blendpos
, positions
, count
* sizeof(REAL
));
1305 GdipFree(brush
->blendfac
);
1306 GdipFree(brush
->blendpos
);
1308 brush
->blendcount
= count
;
1309 brush
->blendfac
= new_blendfac
;
1310 brush
->blendpos
= new_blendpos
;
1315 GpStatus WINGDIPAPI
GdipGetLineBlend(GpLineGradient
*brush
, REAL
*factors
,
1316 REAL
*positions
, INT count
)
1318 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1320 if (!brush
|| !factors
|| !positions
|| count
<= 0)
1321 return InvalidParameter
;
1323 if (count
< brush
->blendcount
)
1324 return InsufficientBuffer
;
1326 memcpy(factors
, brush
->blendfac
, brush
->blendcount
* sizeof(REAL
));
1327 memcpy(positions
, brush
->blendpos
, brush
->blendcount
* sizeof(REAL
));
1332 GpStatus WINGDIPAPI
GdipGetLineBlendCount(GpLineGradient
*brush
, INT
*count
)
1334 TRACE("(%p, %p)\n", brush
, count
);
1336 if (!brush
|| !count
)
1337 return InvalidParameter
;
1339 *count
= brush
->blendcount
;
1344 GpStatus WINGDIPAPI
GdipSetLineGammaCorrection(GpLineGradient
*line
,
1347 TRACE("(%p, %d)\n", line
, usegamma
);
1350 return InvalidParameter
;
1352 line
->gamma
= usegamma
;
1357 GpStatus WINGDIPAPI
GdipSetLineSigmaBlend(GpLineGradient
*line
, REAL focus
,
1364 const int precision
= 16;
1365 REAL erf_range
; /* we use values erf(-erf_range) through erf(+erf_range) */
1369 TRACE("(%p, %0.2f, %0.2f)\n", line
, focus
, scale
);
1371 if(!line
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1372 return InvalidParameter
;
1374 /* we want 2 standard deviations */
1375 erf_range
= 2.0 / sqrt(2);
1377 /* calculate the constants we need to normalize the error function to be
1378 between 0.0 and scale over the range we need */
1379 min_erf
= erf(-erf_range
);
1380 scale_erf
= scale
/ (-2.0 * min_erf
);
1386 for (i
=1; i
<precision
; i
++)
1388 positions
[i
] = focus
* i
/ precision
;
1389 factors
[i
] = scale_erf
* (erf(2 * erf_range
* i
/ precision
- erf_range
) - min_erf
);
1391 num_points
+= precision
;
1394 positions
[num_points
] = focus
;
1395 factors
[num_points
] = scale
;
1400 for (i
=1; i
<precision
; i
++)
1402 positions
[i
+num_points
-1] = (focus
+ ((1.0-focus
) * i
/ precision
));
1403 factors
[i
+num_points
-1] = scale_erf
* (erf(erf_range
- 2 * erf_range
* i
/ precision
) - min_erf
);
1405 num_points
+= precision
;
1406 positions
[num_points
-1] = 1.0;
1407 factors
[num_points
-1] = 0.0;
1410 return GdipSetLineBlend(line
, factors
, positions
, num_points
);
1413 GpStatus WINGDIPAPI
GdipSetLineWrapMode(GpLineGradient
*line
,
1416 TRACE("(%p, %d)\n", line
, wrap
);
1418 if(!line
|| wrap
== WrapModeClamp
)
1419 return InvalidParameter
;
1426 GpStatus WINGDIPAPI
GdipSetPathGradientBlend(GpPathGradient
*brush
, GDIPCONST REAL
*blend
,
1427 GDIPCONST REAL
*pos
, INT count
)
1431 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, pos
, count
);
1434 FIXME("not implemented\n");
1436 return NotImplemented
;
1439 GpStatus WINGDIPAPI
GdipSetPathGradientLinearBlend(GpPathGradient
*brush
,
1440 REAL focus
, REAL scale
)
1444 TRACE("(%p,%0.2f,%0.2f)\n", brush
, focus
, scale
);
1447 FIXME("not implemented\n");
1449 return NotImplemented
;
1452 GpStatus WINGDIPAPI
GdipSetPathGradientPresetBlend(GpPathGradient
*brush
,
1453 GDIPCONST ARGB
*blend
, GDIPCONST REAL
*pos
, INT count
)
1457 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, pos
, count
);
1459 if (!brush
|| !blend
|| !pos
|| count
< 2 ||
1460 pos
[0] != 0.0f
|| pos
[count
-1] != 1.0f
)
1462 return InvalidParameter
;
1465 new_color
= GdipAlloc(count
* sizeof(ARGB
));
1466 new_pos
= GdipAlloc(count
* sizeof(REAL
));
1467 if (!new_color
|| !new_pos
)
1469 GdipFree(new_color
);
1474 memcpy(new_color
, blend
, sizeof(ARGB
) * count
);
1475 memcpy(new_pos
, pos
, sizeof(REAL
) * count
);
1477 GdipFree(brush
->pblendcolor
);
1478 GdipFree(brush
->pblendpos
);
1480 brush
->pblendcolor
= new_color
;
1481 brush
->pblendpos
= new_pos
;
1482 brush
->pblendcount
= count
;
1487 GpStatus WINGDIPAPI
GdipGetPathGradientPresetBlend(GpPathGradient
*brush
,
1488 ARGB
*blend
, REAL
*pos
, INT count
)
1490 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, pos
, count
);
1495 if (!brush
|| !blend
|| !pos
|| count
< 2)
1496 return InvalidParameter
;
1498 if (brush
->pblendcount
== 0)
1499 return GenericError
;
1501 if (count
!= brush
->pblendcount
)
1503 /* Native lines up the ends of each array, and copies the destination size. */
1504 FIXME("Braindead behavior on wrong-sized buffer not implemented.\n");
1505 return InvalidParameter
;
1508 memcpy(blend
, brush
->pblendcolor
, sizeof(ARGB
) * brush
->pblendcount
);
1509 memcpy(pos
, brush
->pblendpos
, sizeof(REAL
) * brush
->pblendcount
);
1514 GpStatus WINGDIPAPI
GdipGetPathGradientPresetBlendCount(GpPathGradient
*brush
,
1517 FIXME("(%p,%p): stub\n", brush
, count
);
1519 if (!brush
|| !count
)
1520 return InvalidParameter
;
1522 *count
= brush
->pblendcount
;
1527 GpStatus WINGDIPAPI
GdipSetPathGradientCenterColor(GpPathGradient
*grad
,
1530 TRACE("(%p, %x)\n", grad
, argb
);
1533 return InvalidParameter
;
1535 grad
->centercolor
= argb
;
1539 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPoint(GpPathGradient
*grad
,
1542 TRACE("(%p, %s)\n", grad
, debugstr_pointf(point
));
1545 return InvalidParameter
;
1547 grad
->center
.X
= point
->X
;
1548 grad
->center
.Y
= point
->Y
;
1553 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPointI(GpPathGradient
*grad
,
1558 TRACE("(%p, %p)\n", grad
, point
);
1561 return InvalidParameter
;
1563 ptf
.X
= (REAL
)point
->X
;
1564 ptf
.Y
= (REAL
)point
->Y
;
1566 return GdipSetPathGradientCenterPoint(grad
,&ptf
);
1569 GpStatus WINGDIPAPI
GdipSetPathGradientFocusScales(GpPathGradient
*grad
,
1572 TRACE("(%p, %.2f, %.2f)\n", grad
, x
, y
);
1575 return InvalidParameter
;
1583 GpStatus WINGDIPAPI
GdipSetPathGradientGammaCorrection(GpPathGradient
*grad
,
1586 TRACE("(%p, %d)\n", grad
, gamma
);
1589 return InvalidParameter
;
1591 grad
->gamma
= gamma
;
1596 GpStatus WINGDIPAPI
GdipSetPathGradientSigmaBlend(GpPathGradient
*grad
,
1597 REAL focus
, REAL scale
)
1601 TRACE("(%p,%0.2f,%0.2f)\n", grad
, focus
, scale
);
1603 if(!grad
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1604 return InvalidParameter
;
1607 FIXME("not implemented\n");
1609 return NotImplemented
;
1612 GpStatus WINGDIPAPI
GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1613 *grad
, GDIPCONST ARGB
*argb
, INT
*count
)
1615 ARGB
*new_surroundcolors
;
1617 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1619 if(!grad
|| !argb
|| !count
|| (*count
<= 0) ||
1620 (*count
> grad
->path
->pathdata
.Count
))
1621 return InvalidParameter
;
1623 new_surroundcolors
= GdipAlloc(*count
* sizeof(ARGB
));
1624 if (!new_surroundcolors
)
1627 memcpy(new_surroundcolors
, argb
, *count
* sizeof(ARGB
));
1629 GdipFree(grad
->surroundcolors
);
1631 grad
->surroundcolors
= new_surroundcolors
;
1632 grad
->surroundcolorcount
= *count
;
1637 GpStatus WINGDIPAPI
GdipSetPathGradientWrapMode(GpPathGradient
*grad
,
1640 TRACE("(%p, %d)\n", grad
, wrap
);
1643 return InvalidParameter
;
1650 GpStatus WINGDIPAPI
GdipSetPathGradientTransform(GpPathGradient
*grad
,
1655 TRACE("(%p,%p)\n", grad
, matrix
);
1658 FIXME("not implemented\n");
1660 return NotImplemented
;
1663 GpStatus WINGDIPAPI
GdipGetPathGradientTransform(GpPathGradient
*grad
,
1666 TRACE("(%p,%p)\n", grad
, matrix
);
1668 if (!grad
|| !matrix
)
1669 return InvalidParameter
;
1671 memcpy(matrix
, grad
->transform
, sizeof(GpMatrix
));
1676 GpStatus WINGDIPAPI
GdipMultiplyPathGradientTransform(GpPathGradient
*grad
,
1677 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1681 TRACE("(%p,%p,%i)\n", grad
, matrix
, order
);
1684 FIXME("not implemented\n");
1686 return NotImplemented
;
1689 GpStatus WINGDIPAPI
GdipRotatePathGradientTransform(GpPathGradient
*grad
,
1690 REAL angle
, GpMatrixOrder order
)
1694 TRACE("(%p,%0.2f,%i)\n", grad
, angle
, order
);
1697 FIXME("not implemented\n");
1699 return NotImplemented
;
1702 GpStatus WINGDIPAPI
GdipScalePathGradientTransform(GpPathGradient
*grad
,
1703 REAL sx
, REAL sy
, GpMatrixOrder order
)
1707 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad
, sx
, sy
, order
);
1710 FIXME("not implemented\n");
1712 return NotImplemented
;
1715 GpStatus WINGDIPAPI
GdipTranslatePathGradientTransform(GpPathGradient
*grad
,
1716 REAL dx
, REAL dy
, GpMatrixOrder order
)
1720 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad
, dx
, dy
, order
);
1723 FIXME("not implemented\n");
1725 return NotImplemented
;
1728 GpStatus WINGDIPAPI
GdipSetSolidFillColor(GpSolidFill
*sf
, ARGB argb
)
1730 TRACE("(%p, %x)\n", sf
, argb
);
1733 return InvalidParameter
;
1739 /******************************************************************************
1740 * GdipSetTextureTransform [GDIPLUS.@]
1742 GpStatus WINGDIPAPI
GdipSetTextureTransform(GpTexture
*texture
,
1743 GDIPCONST GpMatrix
*matrix
)
1745 TRACE("(%p, %p)\n", texture
, matrix
);
1747 if(!texture
|| !matrix
)
1748 return InvalidParameter
;
1750 memcpy(texture
->transform
, matrix
, sizeof(GpMatrix
));
1755 /******************************************************************************
1756 * GdipSetTextureWrapMode [GDIPLUS.@]
1758 * WrapMode not used, only stored
1760 GpStatus WINGDIPAPI
GdipSetTextureWrapMode(GpTexture
*brush
, GpWrapMode wrapmode
)
1762 TRACE("(%p, %d)\n", brush
, wrapmode
);
1765 return InvalidParameter
;
1767 brush
->imageattributes
->wrap
= wrapmode
;
1772 GpStatus WINGDIPAPI
GdipSetLineColors(GpLineGradient
*brush
, ARGB color1
,
1775 TRACE("(%p, %x, %x)\n", brush
, color1
, color2
);
1778 return InvalidParameter
;
1780 brush
->startcolor
= color1
;
1781 brush
->endcolor
= color2
;
1786 GpStatus WINGDIPAPI
GdipGetLineColors(GpLineGradient
*brush
, ARGB
*colors
)
1788 TRACE("(%p, %p)\n", brush
, colors
);
1790 if(!brush
|| !colors
)
1791 return InvalidParameter
;
1793 colors
[0] = brush
->startcolor
;
1794 colors
[1] = brush
->endcolor
;
1799 /******************************************************************************
1800 * GdipRotateTextureTransform [GDIPLUS.@]
1802 GpStatus WINGDIPAPI
GdipRotateTextureTransform(GpTexture
* brush
, REAL angle
,
1803 GpMatrixOrder order
)
1805 TRACE("(%p, %.2f, %d)\n", brush
, angle
, order
);
1808 return InvalidParameter
;
1810 return GdipRotateMatrix(brush
->transform
, angle
, order
);
1813 GpStatus WINGDIPAPI
GdipSetLineLinearBlend(GpLineGradient
*brush
, REAL focus
,
1820 TRACE("(%p,%.2f,%.2f)\n", brush
, focus
, scale
);
1822 if (!brush
) return InvalidParameter
;
1826 factors
[num_points
] = 0.0;
1827 positions
[num_points
] = 0.0;
1831 factors
[num_points
] = scale
;
1832 positions
[num_points
] = focus
;
1837 factors
[num_points
] = 0.0;
1838 positions
[num_points
] = 1.0;
1842 return GdipSetLineBlend(brush
, factors
, positions
, num_points
);
1845 GpStatus WINGDIPAPI
GdipSetLinePresetBlend(GpLineGradient
*brush
,
1846 GDIPCONST ARGB
*blend
, GDIPCONST REAL
* positions
, INT count
)
1850 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, positions
, count
);
1852 if (!brush
|| !blend
|| !positions
|| count
< 2 ||
1853 positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)
1855 return InvalidParameter
;
1858 new_color
= GdipAlloc(count
* sizeof(ARGB
));
1859 new_pos
= GdipAlloc(count
* sizeof(REAL
));
1860 if (!new_color
|| !new_pos
)
1862 GdipFree(new_color
);
1867 memcpy(new_color
, blend
, sizeof(ARGB
) * count
);
1868 memcpy(new_pos
, positions
, sizeof(REAL
) * count
);
1870 GdipFree(brush
->pblendcolor
);
1871 GdipFree(brush
->pblendpos
);
1873 brush
->pblendcolor
= new_color
;
1874 brush
->pblendpos
= new_pos
;
1875 brush
->pblendcount
= count
;
1880 GpStatus WINGDIPAPI
GdipGetLinePresetBlend(GpLineGradient
*brush
,
1881 ARGB
*blend
, REAL
* positions
, INT count
)
1883 if (!brush
|| !blend
|| !positions
|| count
< 2)
1884 return InvalidParameter
;
1886 if (brush
->pblendcount
== 0)
1887 return GenericError
;
1889 if (count
< brush
->pblendcount
)
1890 return InsufficientBuffer
;
1892 memcpy(blend
, brush
->pblendcolor
, sizeof(ARGB
) * brush
->pblendcount
);
1893 memcpy(positions
, brush
->pblendpos
, sizeof(REAL
) * brush
->pblendcount
);
1898 GpStatus WINGDIPAPI
GdipGetLinePresetBlendCount(GpLineGradient
*brush
,
1901 if (!brush
|| !count
)
1902 return InvalidParameter
;
1904 *count
= brush
->pblendcount
;
1909 GpStatus WINGDIPAPI
GdipResetLineTransform(GpLineGradient
*brush
)
1913 TRACE("(%p)\n", brush
);
1916 FIXME("not implemented\n");
1918 return NotImplemented
;
1921 GpStatus WINGDIPAPI
GdipSetLineTransform(GpLineGradient
*brush
,
1922 GDIPCONST GpMatrix
*matrix
)
1926 TRACE("(%p,%p)\n", brush
, matrix
);
1929 FIXME("not implemented\n");
1931 return NotImplemented
;
1934 GpStatus WINGDIPAPI
GdipGetLineTransform(GpLineGradient
*brush
, GpMatrix
*matrix
)
1938 TRACE("(%p,%p)\n", brush
, matrix
);
1941 FIXME("not implemented\n");
1943 return NotImplemented
;
1946 GpStatus WINGDIPAPI
GdipScaleLineTransform(GpLineGradient
*brush
, REAL sx
, REAL sy
,
1947 GpMatrixOrder order
)
1951 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush
, sx
, sy
, order
);
1954 FIXME("not implemented\n");
1956 return NotImplemented
;
1959 GpStatus WINGDIPAPI
GdipMultiplyLineTransform(GpLineGradient
*brush
,
1960 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1964 TRACE("(%p,%p,%u)\n", brush
, matrix
, order
);
1967 FIXME("not implemented\n");
1969 return NotImplemented
;
1972 GpStatus WINGDIPAPI
GdipTranslateLineTransform(GpLineGradient
* brush
,
1973 REAL dx
, REAL dy
, GpMatrixOrder order
)
1977 TRACE("(%p,%f,%f,%d)\n", brush
, dx
, dy
, order
);
1980 FIXME("not implemented\n");
1985 /******************************************************************************
1986 * GdipTranslateTextureTransform [GDIPLUS.@]
1988 GpStatus WINGDIPAPI
GdipTranslateTextureTransform(GpTexture
* brush
, REAL dx
, REAL dy
,
1989 GpMatrixOrder order
)
1991 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, dx
, dy
, order
);
1994 return InvalidParameter
;
1996 return GdipTranslateMatrix(brush
->transform
, dx
, dy
, order
);
1999 GpStatus WINGDIPAPI
GdipGetLineRect(GpLineGradient
*brush
, GpRectF
*rect
)
2001 TRACE("(%p, %p)\n", brush
, rect
);
2004 return InvalidParameter
;
2006 *rect
= brush
->rect
;
2011 GpStatus WINGDIPAPI
GdipGetLineRectI(GpLineGradient
*brush
, GpRect
*rect
)
2016 TRACE("(%p, %p)\n", brush
, rect
);
2019 return InvalidParameter
;
2021 ret
= GdipGetLineRect(brush
, &rectF
);
2024 rect
->X
= roundr(rectF
.X
);
2025 rect
->Y
= roundr(rectF
.Y
);
2026 rect
->Width
= roundr(rectF
.Width
);
2027 rect
->Height
= roundr(rectF
.Height
);
2033 GpStatus WINGDIPAPI
GdipRotateLineTransform(GpLineGradient
* brush
,
2034 REAL angle
, GpMatrixOrder order
)
2038 TRACE("(%p,%0.2f,%u)\n", brush
, angle
, order
);
2041 return InvalidParameter
;
2044 FIXME("(%p, %.2f, %d) stub\n", brush
, angle
, order
);
2046 return NotImplemented
;