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
);
82 count
= src
->blendcount
;
83 dest
->blendcount
= count
;
84 dest
->blendfac
= GdipAlloc(count
* sizeof(REAL
));
85 dest
->blendpos
= GdipAlloc(count
* sizeof(REAL
));
87 if(!dest
->blendfac
|| !dest
->blendpos
){
88 GdipDeletePath(dest
->path
);
89 GdipFree(dest
->blendfac
);
90 GdipFree(dest
->blendpos
);
95 memcpy(dest
->blendfac
, src
->blendfac
, count
* sizeof(REAL
));
96 memcpy(dest
->blendpos
, src
->blendpos
, count
* sizeof(REAL
));
100 case BrushTypeLinearGradient
:{
101 GpLineGradient
*dest
, *src
;
104 dest
= GdipAlloc(sizeof(GpLineGradient
));
105 if(!dest
) return OutOfMemory
;
107 src
= (GpLineGradient
*)brush
;
109 memcpy(dest
, src
, sizeof(GpLineGradient
));
111 count
= dest
->blendcount
;
112 dest
->blendfac
= GdipAlloc(count
* sizeof(REAL
));
113 dest
->blendpos
= GdipAlloc(count
* sizeof(REAL
));
114 pcount
= dest
->pblendcount
;
117 dest
->pblendcolor
= GdipAlloc(pcount
* sizeof(ARGB
));
118 dest
->pblendpos
= GdipAlloc(pcount
* sizeof(REAL
));
121 if (!dest
->blendfac
|| !dest
->blendpos
||
122 (pcount
&& (!dest
->pblendcolor
|| !dest
->pblendpos
)))
124 GdipFree(dest
->blendfac
);
125 GdipFree(dest
->blendpos
);
126 GdipFree(dest
->pblendcolor
);
127 GdipFree(dest
->pblendpos
);
132 memcpy(dest
->blendfac
, src
->blendfac
, count
* sizeof(REAL
));
133 memcpy(dest
->blendpos
, src
->blendpos
, count
* sizeof(REAL
));
137 memcpy(dest
->pblendcolor
, src
->pblendcolor
, pcount
* sizeof(ARGB
));
138 memcpy(dest
->pblendpos
, src
->pblendpos
, pcount
* sizeof(REAL
));
141 *clone
= &dest
->brush
;
144 case BrushTypeTextureFill
:
147 GpTexture
*texture
= (GpTexture
*)brush
;
148 GpTexture
*new_texture
;
151 stat
= GdipGetImageWidth(texture
->image
, &width
);
152 if (stat
!= Ok
) return stat
;
153 stat
= GdipGetImageHeight(texture
->image
, &height
);
154 if (stat
!= Ok
) return stat
;
156 stat
= GdipCreateTextureIA(texture
->image
, texture
->imageattributes
, 0, 0, width
, height
, &new_texture
);
160 memcpy(new_texture
->transform
, texture
->transform
, sizeof(GpMatrix
));
161 *clone
= (GpBrush
*)new_texture
;
169 ERR("not implemented for brush type %d\n", brush
->bt
);
170 return NotImplemented
;
173 TRACE("<-- %p\n", *clone
);
177 static const char HatchBrushes
[][8] = {
178 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HatchStyleHorizontal */
179 { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleVertical */
180 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HatchStyleForwardDiagonal */
181 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HatchStyleBackwardDiagonal */
182 { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HatchStyleCross */
183 { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HatchStyleDiagonalCross */
184 { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80 }, /* HatchStyle05Percent */
185 { 0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88 }, /* HatchStyle10Percent */
186 { 0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc }, /* HatchStyle20Percent */
187 { 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc }, /* HatchStyle25Percent */
188 { 0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc }, /* HatchStyle30Percent */
189 { 0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc }, /* HatchStyle40Percent */
190 { 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc }, /* HatchStyle50Percent */
191 { 0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee }, /* HatchStyle60Percent */
192 { 0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff }, /* HatchStyle70Percent */
193 { 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff }, /* HatchStyle75Percent */
194 { 0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff }, /* HatchStyle80Percent */
195 { 0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff }, /* HatchStyle90Percent */
196 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }, /* HatchStyleLightDownwardDiagonal */
197 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }, /* HatchStyleLightUpwardDiagonal */
198 { 0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc }, /* HatchStyleDarkDownwardDiagonal */
199 { 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99 }, /* HatchStyleDarkUpwardDiagonal */
200 { 0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0 }, /* HatchStyleWideDownwardDiagonal */
201 { 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1 }, /* HatchStyleWideUpwardDiagonal */
202 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 }, /* HatchStyleLightVertical */
203 { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff }, /* HatchStyleLightHorizontal */
204 { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, /* HatchStyleNarrowVertical */
205 { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }, /* HatchStyleNarrowHorizontal */
206 { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc }, /* HatchStyleDarkVertical */
207 { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff }, /* HatchStyleDarkHorizontal */
210 GpStatus
get_hatch_data(HatchStyle hatchstyle
, const char **result
)
212 if (hatchstyle
< sizeof(HatchBrushes
) / sizeof(HatchBrushes
[0]))
214 *result
= HatchBrushes
[hatchstyle
];
218 return NotImplemented
;
221 /******************************************************************************
222 * GdipCreateHatchBrush [GDIPLUS.@]
224 GpStatus WINGDIPAPI
GdipCreateHatchBrush(HatchStyle hatchstyle
, ARGB forecol
, ARGB backcol
, GpHatch
**brush
)
226 TRACE("(%d, %d, %d, %p)\n", hatchstyle
, forecol
, backcol
, brush
);
228 if(!brush
) return InvalidParameter
;
230 *brush
= GdipAlloc(sizeof(GpHatch
));
231 if (!*brush
) return OutOfMemory
;
233 (*brush
)->brush
.bt
= BrushTypeHatchFill
;
234 (*brush
)->forecol
= forecol
;
235 (*brush
)->backcol
= backcol
;
236 (*brush
)->hatchstyle
= hatchstyle
;
237 TRACE("<-- %p\n", *brush
);
242 /******************************************************************************
243 * GdipCreateLineBrush [GDIPLUS.@]
245 GpStatus WINGDIPAPI
GdipCreateLineBrush(GDIPCONST GpPointF
* startpoint
,
246 GDIPCONST GpPointF
* endpoint
, ARGB startcolor
, ARGB endcolor
,
247 GpWrapMode wrap
, GpLineGradient
**line
)
249 TRACE("(%s, %s, %x, %x, %d, %p)\n", debugstr_pointf(startpoint
),
250 debugstr_pointf(endpoint
), startcolor
, endcolor
, wrap
, line
);
252 if(!line
|| !startpoint
|| !endpoint
|| wrap
== WrapModeClamp
)
253 return InvalidParameter
;
255 if (startpoint
->X
== endpoint
->X
&& startpoint
->Y
== endpoint
->Y
)
258 *line
= GdipAlloc(sizeof(GpLineGradient
));
259 if(!*line
) return OutOfMemory
;
261 (*line
)->brush
.bt
= BrushTypeLinearGradient
;
263 (*line
)->startpoint
.X
= startpoint
->X
;
264 (*line
)->startpoint
.Y
= startpoint
->Y
;
265 (*line
)->endpoint
.X
= endpoint
->X
;
266 (*line
)->endpoint
.Y
= endpoint
->Y
;
267 (*line
)->startcolor
= startcolor
;
268 (*line
)->endcolor
= endcolor
;
269 (*line
)->wrap
= wrap
;
270 (*line
)->gamma
= FALSE
;
272 (*line
)->rect
.X
= (startpoint
->X
< endpoint
->X
? startpoint
->X
: endpoint
->X
);
273 (*line
)->rect
.Y
= (startpoint
->Y
< endpoint
->Y
? startpoint
->Y
: endpoint
->Y
);
274 (*line
)->rect
.Width
= fabs(startpoint
->X
- endpoint
->X
);
275 (*line
)->rect
.Height
= fabs(startpoint
->Y
- endpoint
->Y
);
277 if ((*line
)->rect
.Width
== 0)
279 (*line
)->rect
.X
-= (*line
)->rect
.Height
/ 2.0f
;
280 (*line
)->rect
.Width
= (*line
)->rect
.Height
;
282 else if ((*line
)->rect
.Height
== 0)
284 (*line
)->rect
.Y
-= (*line
)->rect
.Width
/ 2.0f
;
285 (*line
)->rect
.Height
= (*line
)->rect
.Width
;
288 (*line
)->blendcount
= 1;
289 (*line
)->blendfac
= GdipAlloc(sizeof(REAL
));
290 (*line
)->blendpos
= GdipAlloc(sizeof(REAL
));
292 if (!(*line
)->blendfac
|| !(*line
)->blendpos
)
294 GdipFree((*line
)->blendfac
);
295 GdipFree((*line
)->blendpos
);
301 (*line
)->blendfac
[0] = 1.0f
;
302 (*line
)->blendpos
[0] = 1.0f
;
304 (*line
)->pblendcolor
= NULL
;
305 (*line
)->pblendpos
= NULL
;
306 (*line
)->pblendcount
= 0;
308 TRACE("<-- %p\n", *line
);
313 GpStatus WINGDIPAPI
GdipCreateLineBrushI(GDIPCONST GpPoint
* startpoint
,
314 GDIPCONST GpPoint
* endpoint
, ARGB startcolor
, ARGB endcolor
,
315 GpWrapMode wrap
, GpLineGradient
**line
)
320 TRACE("(%p, %p, %x, %x, %d, %p)\n", startpoint
, endpoint
,
321 startcolor
, endcolor
, wrap
, line
);
323 if(!startpoint
|| !endpoint
)
324 return InvalidParameter
;
326 stF
.X
= (REAL
)startpoint
->X
;
327 stF
.Y
= (REAL
)startpoint
->Y
;
328 endF
.X
= (REAL
)endpoint
->X
;
329 endF
.Y
= (REAL
)endpoint
->Y
;
331 return GdipCreateLineBrush(&stF
, &endF
, startcolor
, endcolor
, wrap
, line
);
334 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRect(GDIPCONST GpRectF
* rect
,
335 ARGB startcolor
, ARGB endcolor
, LinearGradientMode mode
, GpWrapMode wrap
,
336 GpLineGradient
**line
)
341 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect
, startcolor
, endcolor
, mode
,
345 return InvalidParameter
;
349 case LinearGradientModeHorizontal
:
352 end
.X
= rect
->X
+ rect
->Width
;
355 case LinearGradientModeVertical
:
359 end
.Y
= rect
->Y
+ rect
->Height
;
361 case LinearGradientModeForwardDiagonal
:
364 end
.X
= rect
->X
+ rect
->Width
;
365 end
.Y
= rect
->Y
+ rect
->Height
;
367 case LinearGradientModeBackwardDiagonal
:
368 start
.X
= rect
->X
+ rect
->Width
;
371 end
.Y
= rect
->Y
+ rect
->Height
;
374 return InvalidParameter
;
377 stat
= GdipCreateLineBrush(&start
, &end
, startcolor
, endcolor
, wrap
, line
);
380 (*line
)->rect
= *rect
;
385 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectI(GDIPCONST GpRect
* rect
,
386 ARGB startcolor
, ARGB endcolor
, LinearGradientMode mode
, GpWrapMode wrap
,
387 GpLineGradient
**line
)
391 TRACE("(%p, %x, %x, %d, %d, %p)\n", rect
, startcolor
, endcolor
, mode
,
394 rectF
.X
= (REAL
) rect
->X
;
395 rectF
.Y
= (REAL
) rect
->Y
;
396 rectF
.Width
= (REAL
) rect
->Width
;
397 rectF
.Height
= (REAL
) rect
->Height
;
399 return GdipCreateLineBrushFromRect(&rectF
, startcolor
, endcolor
, mode
, wrap
, line
);
402 /******************************************************************************
403 * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
405 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF
* rect
,
406 ARGB startcolor
, ARGB endcolor
, REAL angle
, BOOL isAngleScalable
, GpWrapMode wrap
,
407 GpLineGradient
**line
)
410 LinearGradientMode mode
;
411 REAL width
, height
, exofs
, eyofs
;
412 REAL sin_angle
, cos_angle
, sin_cos_angle
;
414 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect
, startcolor
, endcolor
, angle
, isAngleScalable
,
417 sin_angle
= sinf(deg2rad(angle
));
418 cos_angle
= cosf(deg2rad(angle
));
419 sin_cos_angle
= sin_angle
* cos_angle
;
423 width
= height
= 1.0;
428 height
= rect
->Height
;
431 if (sin_cos_angle
>= 0)
432 mode
= LinearGradientModeForwardDiagonal
;
434 mode
= LinearGradientModeBackwardDiagonal
;
436 stat
= GdipCreateLineBrushFromRect(rect
, startcolor
, endcolor
, mode
, wrap
, line
);
440 if (sin_cos_angle
>= 0)
442 exofs
= width
* sin_cos_angle
+ height
* cos_angle
* cos_angle
;
443 eyofs
= width
* sin_angle
* sin_angle
+ height
* sin_cos_angle
;
447 exofs
= width
* sin_angle
* sin_angle
+ height
* sin_cos_angle
;
448 eyofs
= -width
* sin_cos_angle
+ height
* sin_angle
* sin_angle
;
453 exofs
= exofs
* rect
->Width
;
454 eyofs
= eyofs
* rect
->Height
;
459 (*line
)->endpoint
.X
= rect
->X
+ exofs
;
460 (*line
)->endpoint
.Y
= rect
->Y
+ eyofs
;
464 (*line
)->endpoint
.X
= (*line
)->startpoint
.X
;
465 (*line
)->endpoint
.Y
= (*line
)->startpoint
.Y
;
466 (*line
)->startpoint
.X
= rect
->X
+ exofs
;
467 (*line
)->startpoint
.Y
= rect
->Y
+ eyofs
;
474 GpStatus WINGDIPAPI
GdipCreateLineBrushFromRectWithAngleI(GDIPCONST GpRect
* rect
,
475 ARGB startcolor
, ARGB endcolor
, REAL angle
, BOOL isAngleScalable
, GpWrapMode wrap
,
476 GpLineGradient
**line
)
478 TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect
, startcolor
, endcolor
, angle
, isAngleScalable
,
481 return GdipCreateLineBrushFromRectI(rect
, startcolor
, endcolor
, LinearGradientModeForwardDiagonal
,
485 static GpStatus
create_path_gradient(GpPath
*path
, GpPathGradient
**grad
)
488 return InvalidParameter
;
490 *grad
= GdipAlloc(sizeof(GpPathGradient
));
496 (*grad
)->blendfac
= GdipAlloc(sizeof(REAL
));
497 (*grad
)->blendpos
= GdipAlloc(sizeof(REAL
));
498 if(!(*grad
)->blendfac
|| !(*grad
)->blendpos
){
499 GdipFree((*grad
)->blendfac
);
500 GdipFree((*grad
)->blendpos
);
505 (*grad
)->blendfac
[0] = 1.0;
506 (*grad
)->blendpos
[0] = 1.0;
507 (*grad
)->blendcount
= 1;
509 (*grad
)->path
= path
;
511 (*grad
)->brush
.bt
= BrushTypePathGradient
;
512 (*grad
)->centercolor
= 0xffffffff;
513 (*grad
)->wrap
= WrapModeClamp
;
514 (*grad
)->gamma
= FALSE
;
515 /* FIXME: this should be set to the "centroid" of the path by default */
516 (*grad
)->center
.X
= 0.0;
517 (*grad
)->center
.Y
= 0.0;
518 (*grad
)->focus
.X
= 0.0;
519 (*grad
)->focus
.Y
= 0.0;
521 TRACE("<-- %p\n", *grad
);
526 GpStatus WINGDIPAPI
GdipCreatePathGradient(GDIPCONST GpPointF
* points
,
527 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
532 TRACE("(%p, %d, %d, %p)\n", points
, count
, wrap
, grad
);
535 return InvalidParameter
;
540 stat
= GdipCreatePath(FillModeAlternate
, &path
);
544 stat
= GdipAddPathLine2(path
, points
, count
);
547 stat
= create_path_gradient(path
, grad
);
550 GdipDeletePath(path
);
556 GpStatus WINGDIPAPI
GdipCreatePathGradientI(GDIPCONST GpPoint
* points
,
557 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
562 TRACE("(%p, %d, %d, %p)\n", points
, count
, wrap
, grad
);
565 return InvalidParameter
;
570 stat
= GdipCreatePath(FillModeAlternate
, &path
);
574 stat
= GdipAddPathLine2I(path
, points
, count
);
577 stat
= create_path_gradient(path
, grad
);
580 GdipDeletePath(path
);
586 /******************************************************************************
587 * GdipCreatePathGradientFromPath [GDIPLUS.@]
589 GpStatus WINGDIPAPI
GdipCreatePathGradientFromPath(GDIPCONST GpPath
* path
,
590 GpPathGradient
**grad
)
595 TRACE("(%p, %p)\n", path
, grad
);
598 return InvalidParameter
;
600 stat
= GdipClonePath((GpPath
*)path
, &new_path
);
604 stat
= create_path_gradient(new_path
, grad
);
607 GdipDeletePath(new_path
);
613 /******************************************************************************
614 * GdipCreateSolidFill [GDIPLUS.@]
616 GpStatus WINGDIPAPI
GdipCreateSolidFill(ARGB color
, GpSolidFill
**sf
)
618 TRACE("(%x, %p)\n", color
, sf
);
620 if(!sf
) return InvalidParameter
;
622 *sf
= GdipAlloc(sizeof(GpSolidFill
));
623 if (!*sf
) return OutOfMemory
;
625 (*sf
)->brush
.bt
= BrushTypeSolidColor
;
626 (*sf
)->color
= color
;
628 TRACE("<-- %p\n", *sf
);
633 /******************************************************************************
634 * GdipCreateTexture [GDIPLUS.@]
637 * image [I] image to use
638 * wrapmode [I] optional
639 * texture [O] pointer to the resulting texturebrush
643 * FAILURE: element of GpStatus
645 GpStatus WINGDIPAPI
GdipCreateTexture(GpImage
*image
, GpWrapMode wrapmode
,
649 GpImageAttributes
*attributes
;
652 TRACE("%p, %d %p\n", image
, wrapmode
, texture
);
654 if (!(image
&& texture
))
655 return InvalidParameter
;
657 stat
= GdipGetImageWidth(image
, &width
);
658 if (stat
!= Ok
) return stat
;
659 stat
= GdipGetImageHeight(image
, &height
);
660 if (stat
!= Ok
) return stat
;
662 stat
= GdipCreateImageAttributes(&attributes
);
666 attributes
->wrap
= wrapmode
;
668 stat
= GdipCreateTextureIA(image
, attributes
, 0, 0, width
, height
,
671 GdipDisposeImageAttributes(attributes
);
677 /******************************************************************************
678 * GdipCreateTexture2 [GDIPLUS.@]
680 GpStatus WINGDIPAPI
GdipCreateTexture2(GpImage
*image
, GpWrapMode wrapmode
,
681 REAL x
, REAL y
, REAL width
, REAL height
, GpTexture
**texture
)
683 GpImageAttributes
*attributes
;
686 TRACE("%p %d %f %f %f %f %p\n", image
, wrapmode
,
687 x
, y
, width
, height
, texture
);
689 stat
= GdipCreateImageAttributes(&attributes
);
693 attributes
->wrap
= wrapmode
;
695 stat
= GdipCreateTextureIA(image
, attributes
, x
, y
, width
, height
,
698 GdipDisposeImageAttributes(attributes
);
704 /******************************************************************************
705 * GdipCreateTextureIA [GDIPLUS.@]
707 * FIXME: imageattr ignored
709 GpStatus WINGDIPAPI
GdipCreateTextureIA(GpImage
*image
,
710 GDIPCONST GpImageAttributes
*imageattr
, REAL x
, REAL y
, REAL width
,
711 REAL height
, GpTexture
**texture
)
714 GpImage
*new_image
=NULL
;
716 TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image
, imageattr
, x
, y
, width
, height
,
719 if(!image
|| !texture
|| x
< 0.0 || y
< 0.0 || width
< 0.0 || height
< 0.0)
720 return InvalidParameter
;
724 if(image
->type
!= ImageTypeBitmap
){
725 FIXME("not implemented for image type %d\n", image
->type
);
726 return NotImplemented
;
729 status
= GdipCloneBitmapArea(x
, y
, width
, height
, PixelFormatDontCare
, (GpBitmap
*)image
, (GpBitmap
**)&new_image
);
733 *texture
= GdipAlloc(sizeof(GpTexture
));
735 status
= OutOfMemory
;
739 if((status
= GdipCreateMatrix(&(*texture
)->transform
)) != Ok
){
745 status
= GdipCloneImageAttributes(imageattr
, &(*texture
)->imageattributes
);
749 status
= GdipCreateImageAttributes(&(*texture
)->imageattributes
);
751 (*texture
)->imageattributes
->wrap
= WrapModeTile
;
755 (*texture
)->brush
.bt
= BrushTypeTextureFill
;
756 (*texture
)->image
= new_image
;
762 TRACE("<-- %p\n", *texture
);
768 GdipDeleteMatrix((*texture
)->transform
);
769 GdipDisposeImageAttributes((*texture
)->imageattributes
);
773 GdipDisposeImage(new_image
);
774 TRACE("<-- error %u\n", status
);
780 /******************************************************************************
781 * GdipCreateTextureIAI [GDIPLUS.@]
783 GpStatus WINGDIPAPI
GdipCreateTextureIAI(GpImage
*image
, GDIPCONST GpImageAttributes
*imageattr
,
784 INT x
, INT y
, INT width
, INT height
, GpTexture
**texture
)
786 TRACE("(%p, %p, %d, %d, %d, %d, %p)\n", image
, imageattr
, x
, y
, width
, height
,
789 return GdipCreateTextureIA(image
,imageattr
,(REAL
)x
,(REAL
)y
,(REAL
)width
,(REAL
)height
,texture
);
792 GpStatus WINGDIPAPI
GdipCreateTexture2I(GpImage
*image
, GpWrapMode wrapmode
,
793 INT x
, INT y
, INT width
, INT height
, GpTexture
**texture
)
795 GpImageAttributes
*imageattr
;
798 TRACE("%p %d %d %d %d %d %p\n", image
, wrapmode
, x
, y
, width
, height
,
801 stat
= GdipCreateImageAttributes(&imageattr
);
805 imageattr
->wrap
= wrapmode
;
807 stat
= GdipCreateTextureIA(image
, imageattr
, x
, y
, width
, height
, texture
);
813 GpStatus WINGDIPAPI
GdipGetBrushType(GpBrush
*brush
, GpBrushType
*type
)
815 TRACE("(%p, %p)\n", brush
, type
);
817 if(!brush
|| !type
) return InvalidParameter
;
824 GpStatus WINGDIPAPI
GdipGetHatchBackgroundColor(GpHatch
*brush
, ARGB
*backcol
)
826 TRACE("(%p, %p)\n", brush
, backcol
);
828 if(!brush
|| !backcol
) return InvalidParameter
;
830 *backcol
= brush
->backcol
;
835 GpStatus WINGDIPAPI
GdipGetHatchForegroundColor(GpHatch
*brush
, ARGB
*forecol
)
837 TRACE("(%p, %p)\n", brush
, forecol
);
839 if(!brush
|| !forecol
) return InvalidParameter
;
841 *forecol
= brush
->forecol
;
846 GpStatus WINGDIPAPI
GdipGetHatchStyle(GpHatch
*brush
, HatchStyle
*hatchstyle
)
848 TRACE("(%p, %p)\n", brush
, hatchstyle
);
850 if(!brush
|| !hatchstyle
) return InvalidParameter
;
852 *hatchstyle
= brush
->hatchstyle
;
857 GpStatus WINGDIPAPI
GdipDeleteBrush(GpBrush
*brush
)
859 TRACE("(%p)\n", brush
);
861 if(!brush
) return InvalidParameter
;
865 case BrushTypePathGradient
:
866 GdipDeletePath(((GpPathGradient
*) brush
)->path
);
867 GdipFree(((GpPathGradient
*) brush
)->blendfac
);
868 GdipFree(((GpPathGradient
*) brush
)->blendpos
);
870 case BrushTypeLinearGradient
:
871 GdipFree(((GpLineGradient
*)brush
)->blendfac
);
872 GdipFree(((GpLineGradient
*)brush
)->blendpos
);
873 GdipFree(((GpLineGradient
*)brush
)->pblendcolor
);
874 GdipFree(((GpLineGradient
*)brush
)->pblendpos
);
876 case BrushTypeTextureFill
:
877 GdipDeleteMatrix(((GpTexture
*)brush
)->transform
);
878 GdipDisposeImage(((GpTexture
*)brush
)->image
);
879 GdipDisposeImageAttributes(((GpTexture
*)brush
)->imageattributes
);
880 GdipFree(((GpTexture
*)brush
)->bitmap_bits
);
891 GpStatus WINGDIPAPI
GdipGetLineGammaCorrection(GpLineGradient
*line
,
894 TRACE("(%p, %p)\n", line
, usinggamma
);
896 if(!line
|| !usinggamma
)
897 return InvalidParameter
;
899 *usinggamma
= line
->gamma
;
904 GpStatus WINGDIPAPI
GdipGetLineWrapMode(GpLineGradient
*brush
, GpWrapMode
*wrapmode
)
906 TRACE("(%p, %p)\n", brush
, wrapmode
);
908 if(!brush
|| !wrapmode
)
909 return InvalidParameter
;
911 *wrapmode
= brush
->wrap
;
916 GpStatus WINGDIPAPI
GdipGetPathGradientBlend(GpPathGradient
*brush
, REAL
*blend
,
917 REAL
*positions
, INT count
)
919 TRACE("(%p, %p, %p, %d)\n", brush
, blend
, positions
, count
);
921 if(!brush
|| !blend
|| !positions
|| count
<= 0)
922 return InvalidParameter
;
924 if(count
< brush
->blendcount
)
925 return InsufficientBuffer
;
927 memcpy(blend
, brush
->blendfac
, count
*sizeof(REAL
));
928 if(brush
->blendcount
> 1){
929 memcpy(positions
, brush
->blendpos
, count
*sizeof(REAL
));
935 GpStatus WINGDIPAPI
GdipGetPathGradientBlendCount(GpPathGradient
*brush
, INT
*count
)
937 TRACE("(%p, %p)\n", brush
, count
);
940 return InvalidParameter
;
942 *count
= brush
->blendcount
;
947 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPoint(GpPathGradient
*grad
,
950 TRACE("(%p, %p)\n", grad
, point
);
953 return InvalidParameter
;
955 point
->X
= grad
->center
.X
;
956 point
->Y
= grad
->center
.Y
;
961 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPointI(GpPathGradient
*grad
,
967 TRACE("(%p, %p)\n", grad
, point
);
970 return InvalidParameter
;
972 ret
= GdipGetPathGradientCenterPoint(grad
,&ptf
);
975 point
->X
= roundr(ptf
.X
);
976 point
->Y
= roundr(ptf
.Y
);
982 GpStatus WINGDIPAPI
GdipGetPathGradientCenterColor(GpPathGradient
*grad
,
987 TRACE("(%p,%p)\n", grad
, colors
);
990 FIXME("not implemented\n");
992 return NotImplemented
;
995 GpStatus WINGDIPAPI
GdipGetPathGradientFocusScales(GpPathGradient
*grad
,
998 TRACE("(%p, %p, %p)\n", grad
, x
, y
);
1000 if(!grad
|| !x
|| !y
)
1001 return InvalidParameter
;
1009 GpStatus WINGDIPAPI
GdipGetPathGradientGammaCorrection(GpPathGradient
*grad
,
1012 TRACE("(%p, %p)\n", grad
, gamma
);
1015 return InvalidParameter
;
1017 *gamma
= grad
->gamma
;
1022 GpStatus WINGDIPAPI
GdipGetPathGradientPath(GpPathGradient
*grad
, GpPath
*path
)
1026 TRACE("(%p, %p)\n", grad
, path
);
1029 FIXME("not implemented\n");
1031 return NotImplemented
;
1034 GpStatus WINGDIPAPI
GdipGetPathGradientPointCount(GpPathGradient
*grad
,
1037 TRACE("(%p, %p)\n", grad
, count
);
1040 return InvalidParameter
;
1042 *count
= grad
->path
->pathdata
.Count
;
1047 GpStatus WINGDIPAPI
GdipGetPathGradientRect(GpPathGradient
*brush
, GpRectF
*rect
)
1051 TRACE("(%p, %p)\n", brush
, rect
);
1054 return InvalidParameter
;
1056 stat
= GdipGetPathWorldBounds(brush
->path
, rect
, NULL
, NULL
);
1061 GpStatus WINGDIPAPI
GdipGetPathGradientRectI(GpPathGradient
*brush
, GpRect
*rect
)
1066 TRACE("(%p, %p)\n", brush
, rect
);
1069 return InvalidParameter
;
1071 stat
= GdipGetPathGradientRect(brush
, &rectf
);
1072 if(stat
!= Ok
) return stat
;
1074 rect
->X
= roundr(rectf
.X
);
1075 rect
->Y
= roundr(rectf
.Y
);
1076 rect
->Width
= roundr(rectf
.Width
);
1077 rect
->Height
= roundr(rectf
.Height
);
1082 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1083 *grad
, ARGB
*argb
, INT
*count
)
1087 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1089 if(!grad
|| !argb
|| !count
|| (*count
< grad
->path
->pathdata
.Count
))
1090 return InvalidParameter
;
1093 FIXME("not implemented\n");
1095 return NotImplemented
;
1098 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorCount(GpPathGradient
*brush
, INT
*count
)
1102 TRACE("(%p, %p)\n", brush
, count
);
1104 if (!brush
|| !count
)
1105 return InvalidParameter
;
1108 FIXME("not implemented\n");
1110 return NotImplemented
;
1113 GpStatus WINGDIPAPI
GdipGetPathGradientWrapMode(GpPathGradient
*brush
,
1114 GpWrapMode
*wrapmode
)
1116 TRACE("(%p, %p)\n", brush
, wrapmode
);
1118 if(!brush
|| !wrapmode
)
1119 return InvalidParameter
;
1121 *wrapmode
= brush
->wrap
;
1126 GpStatus WINGDIPAPI
GdipGetSolidFillColor(GpSolidFill
*sf
, ARGB
*argb
)
1128 TRACE("(%p, %p)\n", sf
, argb
);
1131 return InvalidParameter
;
1138 /******************************************************************************
1139 * GdipGetTextureImage [GDIPLUS.@]
1141 GpStatus WINGDIPAPI
GdipGetTextureImage(GpTexture
*brush
, GpImage
**image
)
1143 TRACE("(%p, %p)\n", brush
, image
);
1145 if(!brush
|| !image
)
1146 return InvalidParameter
;
1148 return GdipCloneImage(brush
->image
, image
);
1151 /******************************************************************************
1152 * GdipGetTextureTransform [GDIPLUS.@]
1154 GpStatus WINGDIPAPI
GdipGetTextureTransform(GpTexture
*brush
, GpMatrix
*matrix
)
1156 TRACE("(%p, %p)\n", brush
, matrix
);
1158 if(!brush
|| !matrix
)
1159 return InvalidParameter
;
1161 memcpy(matrix
, brush
->transform
, sizeof(GpMatrix
));
1166 /******************************************************************************
1167 * GdipGetTextureWrapMode [GDIPLUS.@]
1169 GpStatus WINGDIPAPI
GdipGetTextureWrapMode(GpTexture
*brush
, GpWrapMode
*wrapmode
)
1171 TRACE("(%p, %p)\n", brush
, wrapmode
);
1173 if(!brush
|| !wrapmode
)
1174 return InvalidParameter
;
1176 *wrapmode
= brush
->imageattributes
->wrap
;
1181 /******************************************************************************
1182 * GdipMultiplyTextureTransform [GDIPLUS.@]
1184 GpStatus WINGDIPAPI
GdipMultiplyTextureTransform(GpTexture
* brush
,
1185 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1187 TRACE("(%p, %p, %d)\n", brush
, matrix
, order
);
1189 if(!brush
|| !matrix
)
1190 return InvalidParameter
;
1192 return GdipMultiplyMatrix(brush
->transform
, matrix
, order
);
1195 /******************************************************************************
1196 * GdipResetTextureTransform [GDIPLUS.@]
1198 GpStatus WINGDIPAPI
GdipResetTextureTransform(GpTexture
* brush
)
1200 TRACE("(%p)\n", brush
);
1203 return InvalidParameter
;
1205 return GdipSetMatrixElements(brush
->transform
, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1208 /******************************************************************************
1209 * GdipScaleTextureTransform [GDIPLUS.@]
1211 GpStatus WINGDIPAPI
GdipScaleTextureTransform(GpTexture
* brush
,
1212 REAL sx
, REAL sy
, GpMatrixOrder order
)
1214 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, sx
, sy
, order
);
1217 return InvalidParameter
;
1219 return GdipScaleMatrix(brush
->transform
, sx
, sy
, order
);
1222 GpStatus WINGDIPAPI
GdipSetLineBlend(GpLineGradient
*brush
,
1223 GDIPCONST REAL
*factors
, GDIPCONST REAL
* positions
, INT count
)
1225 REAL
*new_blendfac
, *new_blendpos
;
1227 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1229 if(!brush
|| !factors
|| !positions
|| count
<= 0 ||
1230 (count
>= 2 && (positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)))
1231 return InvalidParameter
;
1233 new_blendfac
= GdipAlloc(count
* sizeof(REAL
));
1234 new_blendpos
= GdipAlloc(count
* sizeof(REAL
));
1236 if (!new_blendfac
|| !new_blendpos
)
1238 GdipFree(new_blendfac
);
1239 GdipFree(new_blendpos
);
1243 memcpy(new_blendfac
, factors
, count
* sizeof(REAL
));
1244 memcpy(new_blendpos
, positions
, count
* sizeof(REAL
));
1246 GdipFree(brush
->blendfac
);
1247 GdipFree(brush
->blendpos
);
1249 brush
->blendcount
= count
;
1250 brush
->blendfac
= new_blendfac
;
1251 brush
->blendpos
= new_blendpos
;
1256 GpStatus WINGDIPAPI
GdipGetLineBlend(GpLineGradient
*brush
, REAL
*factors
,
1257 REAL
*positions
, INT count
)
1259 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1261 if (!brush
|| !factors
|| !positions
|| count
<= 0)
1262 return InvalidParameter
;
1264 if (count
< brush
->blendcount
)
1265 return InsufficientBuffer
;
1267 memcpy(factors
, brush
->blendfac
, brush
->blendcount
* sizeof(REAL
));
1268 memcpy(positions
, brush
->blendpos
, brush
->blendcount
* sizeof(REAL
));
1273 GpStatus WINGDIPAPI
GdipGetLineBlendCount(GpLineGradient
*brush
, INT
*count
)
1275 TRACE("(%p, %p)\n", brush
, count
);
1277 if (!brush
|| !count
)
1278 return InvalidParameter
;
1280 *count
= brush
->blendcount
;
1285 GpStatus WINGDIPAPI
GdipSetLineGammaCorrection(GpLineGradient
*line
,
1288 TRACE("(%p, %d)\n", line
, usegamma
);
1291 return InvalidParameter
;
1293 line
->gamma
= usegamma
;
1298 GpStatus WINGDIPAPI
GdipSetLineSigmaBlend(GpLineGradient
*line
, REAL focus
,
1305 const int precision
= 16;
1306 REAL erf_range
; /* we use values erf(-erf_range) through erf(+erf_range) */
1310 TRACE("(%p, %0.2f, %0.2f)\n", line
, focus
, scale
);
1312 if(!line
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1313 return InvalidParameter
;
1315 /* we want 2 standard deviations */
1316 erf_range
= 2.0 / sqrt(2);
1318 /* calculate the constants we need to normalize the error function to be
1319 between 0.0 and scale over the range we need */
1320 min_erf
= erf(-erf_range
);
1321 scale_erf
= scale
/ (-2.0 * min_erf
);
1327 for (i
=1; i
<precision
; i
++)
1329 positions
[i
] = focus
* i
/ precision
;
1330 factors
[i
] = scale_erf
* (erf(2 * erf_range
* i
/ precision
- erf_range
) - min_erf
);
1332 num_points
+= precision
;
1335 positions
[num_points
] = focus
;
1336 factors
[num_points
] = scale
;
1341 for (i
=1; i
<precision
; i
++)
1343 positions
[i
+num_points
-1] = (focus
+ ((1.0-focus
) * i
/ precision
));
1344 factors
[i
+num_points
-1] = scale_erf
* (erf(erf_range
- 2 * erf_range
* i
/ precision
) - min_erf
);
1346 num_points
+= precision
;
1347 positions
[num_points
-1] = 1.0;
1348 factors
[num_points
-1] = 0.0;
1351 return GdipSetLineBlend(line
, factors
, positions
, num_points
);
1354 GpStatus WINGDIPAPI
GdipSetLineWrapMode(GpLineGradient
*line
,
1357 TRACE("(%p, %d)\n", line
, wrap
);
1359 if(!line
|| wrap
== WrapModeClamp
)
1360 return InvalidParameter
;
1367 GpStatus WINGDIPAPI
GdipSetPathGradientBlend(GpPathGradient
*brush
, GDIPCONST REAL
*blend
,
1368 GDIPCONST REAL
*pos
, INT count
)
1372 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, pos
, count
);
1375 FIXME("not implemented\n");
1377 return NotImplemented
;
1380 GpStatus WINGDIPAPI
GdipSetPathGradientLinearBlend(GpPathGradient
*brush
,
1381 REAL focus
, REAL scale
)
1385 TRACE("(%p,%0.2f,%0.2f)\n", brush
, focus
, scale
);
1388 FIXME("not implemented\n");
1390 return NotImplemented
;
1393 GpStatus WINGDIPAPI
GdipSetPathGradientPresetBlend(GpPathGradient
*brush
,
1394 GDIPCONST ARGB
*blend
, GDIPCONST REAL
*pos
, INT count
)
1396 FIXME("(%p,%p,%p,%i): stub\n", brush
, blend
, pos
, count
);
1397 return NotImplemented
;
1400 GpStatus WINGDIPAPI
GdipGetPathGradientPresetBlend(GpPathGradient
*brush
,
1401 ARGB
*blend
, REAL
*pos
, INT count
)
1403 FIXME("(%p,%p,%p,%i): stub\n", brush
, blend
, pos
, count
);
1404 return NotImplemented
;
1407 GpStatus WINGDIPAPI
GdipGetPathGradientPresetBlendCount(GpPathGradient
*brush
,
1410 FIXME("(%p,%p): stub\n", brush
, count
);
1411 return NotImplemented
;
1414 GpStatus WINGDIPAPI
GdipSetPathGradientCenterColor(GpPathGradient
*grad
,
1417 TRACE("(%p, %x)\n", grad
, argb
);
1420 return InvalidParameter
;
1422 grad
->centercolor
= argb
;
1426 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPoint(GpPathGradient
*grad
,
1429 TRACE("(%p, %s)\n", grad
, debugstr_pointf(point
));
1432 return InvalidParameter
;
1434 grad
->center
.X
= point
->X
;
1435 grad
->center
.Y
= point
->Y
;
1440 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPointI(GpPathGradient
*grad
,
1445 TRACE("(%p, %p)\n", grad
, point
);
1448 return InvalidParameter
;
1450 ptf
.X
= (REAL
)point
->X
;
1451 ptf
.Y
= (REAL
)point
->Y
;
1453 return GdipSetPathGradientCenterPoint(grad
,&ptf
);
1456 GpStatus WINGDIPAPI
GdipSetPathGradientFocusScales(GpPathGradient
*grad
,
1459 TRACE("(%p, %.2f, %.2f)\n", grad
, x
, y
);
1462 return InvalidParameter
;
1470 GpStatus WINGDIPAPI
GdipSetPathGradientGammaCorrection(GpPathGradient
*grad
,
1473 TRACE("(%p, %d)\n", grad
, gamma
);
1476 return InvalidParameter
;
1478 grad
->gamma
= gamma
;
1483 GpStatus WINGDIPAPI
GdipSetPathGradientSigmaBlend(GpPathGradient
*grad
,
1484 REAL focus
, REAL scale
)
1488 TRACE("(%p,%0.2f,%0.2f)\n", grad
, focus
, scale
);
1490 if(!grad
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1491 return InvalidParameter
;
1494 FIXME("not implemented\n");
1496 return NotImplemented
;
1499 GpStatus WINGDIPAPI
GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1500 *grad
, GDIPCONST ARGB
*argb
, INT
*count
)
1504 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1506 if(!grad
|| !argb
|| !count
|| (*count
<= 0) ||
1507 (*count
> grad
->path
->pathdata
.Count
))
1508 return InvalidParameter
;
1511 FIXME("not implemented\n");
1513 return NotImplemented
;
1516 GpStatus WINGDIPAPI
GdipSetPathGradientWrapMode(GpPathGradient
*grad
,
1519 TRACE("(%p, %d)\n", grad
, wrap
);
1522 return InvalidParameter
;
1529 GpStatus WINGDIPAPI
GdipSetPathGradientTransform(GpPathGradient
*grad
,
1534 TRACE("(%p,%p)\n", grad
, matrix
);
1537 FIXME("not implemented\n");
1539 return NotImplemented
;
1542 GpStatus WINGDIPAPI
GdipGetPathGradientTransform(GpPathGradient
*grad
,
1547 TRACE("(%p,%p)\n", grad
, matrix
);
1550 FIXME("not implemented\n");
1552 return NotImplemented
;
1555 GpStatus WINGDIPAPI
GdipMultiplyPathGradientTransform(GpPathGradient
*grad
,
1556 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1560 TRACE("(%p,%p,%i)\n", grad
, matrix
, order
);
1563 FIXME("not implemented\n");
1565 return NotImplemented
;
1568 GpStatus WINGDIPAPI
GdipRotatePathGradientTransform(GpPathGradient
*grad
,
1569 REAL angle
, GpMatrixOrder order
)
1573 TRACE("(%p,%0.2f,%i)\n", grad
, angle
, order
);
1576 FIXME("not implemented\n");
1578 return NotImplemented
;
1581 GpStatus WINGDIPAPI
GdipScalePathGradientTransform(GpPathGradient
*grad
,
1582 REAL sx
, REAL sy
, GpMatrixOrder order
)
1586 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad
, sx
, sy
, order
);
1589 FIXME("not implemented\n");
1591 return NotImplemented
;
1594 GpStatus WINGDIPAPI
GdipTranslatePathGradientTransform(GpPathGradient
*grad
,
1595 REAL dx
, REAL dy
, GpMatrixOrder order
)
1599 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad
, dx
, dy
, order
);
1602 FIXME("not implemented\n");
1604 return NotImplemented
;
1607 GpStatus WINGDIPAPI
GdipSetSolidFillColor(GpSolidFill
*sf
, ARGB argb
)
1609 TRACE("(%p, %x)\n", sf
, argb
);
1612 return InvalidParameter
;
1618 /******************************************************************************
1619 * GdipSetTextureTransform [GDIPLUS.@]
1621 GpStatus WINGDIPAPI
GdipSetTextureTransform(GpTexture
*texture
,
1622 GDIPCONST GpMatrix
*matrix
)
1624 TRACE("(%p, %p)\n", texture
, matrix
);
1626 if(!texture
|| !matrix
)
1627 return InvalidParameter
;
1629 memcpy(texture
->transform
, matrix
, sizeof(GpMatrix
));
1634 /******************************************************************************
1635 * GdipSetTextureWrapMode [GDIPLUS.@]
1637 * WrapMode not used, only stored
1639 GpStatus WINGDIPAPI
GdipSetTextureWrapMode(GpTexture
*brush
, GpWrapMode wrapmode
)
1641 TRACE("(%p, %d)\n", brush
, wrapmode
);
1644 return InvalidParameter
;
1646 brush
->imageattributes
->wrap
= wrapmode
;
1651 GpStatus WINGDIPAPI
GdipSetLineColors(GpLineGradient
*brush
, ARGB color1
,
1654 TRACE("(%p, %x, %x)\n", brush
, color1
, color2
);
1657 return InvalidParameter
;
1659 brush
->startcolor
= color1
;
1660 brush
->endcolor
= color2
;
1665 GpStatus WINGDIPAPI
GdipGetLineColors(GpLineGradient
*brush
, ARGB
*colors
)
1667 TRACE("(%p, %p)\n", brush
, colors
);
1669 if(!brush
|| !colors
)
1670 return InvalidParameter
;
1672 colors
[0] = brush
->startcolor
;
1673 colors
[1] = brush
->endcolor
;
1678 /******************************************************************************
1679 * GdipRotateTextureTransform [GDIPLUS.@]
1681 GpStatus WINGDIPAPI
GdipRotateTextureTransform(GpTexture
* brush
, REAL angle
,
1682 GpMatrixOrder order
)
1684 TRACE("(%p, %.2f, %d)\n", brush
, angle
, order
);
1687 return InvalidParameter
;
1689 return GdipRotateMatrix(brush
->transform
, angle
, order
);
1692 GpStatus WINGDIPAPI
GdipSetLineLinearBlend(GpLineGradient
*brush
, REAL focus
,
1699 TRACE("(%p,%.2f,%.2f)\n", brush
, focus
, scale
);
1701 if (!brush
) return InvalidParameter
;
1705 factors
[num_points
] = 0.0;
1706 positions
[num_points
] = 0.0;
1710 factors
[num_points
] = scale
;
1711 positions
[num_points
] = focus
;
1716 factors
[num_points
] = 0.0;
1717 positions
[num_points
] = 1.0;
1721 return GdipSetLineBlend(brush
, factors
, positions
, num_points
);
1724 GpStatus WINGDIPAPI
GdipSetLinePresetBlend(GpLineGradient
*brush
,
1725 GDIPCONST ARGB
*blend
, GDIPCONST REAL
* positions
, INT count
)
1729 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, positions
, count
);
1731 if (!brush
|| !blend
|| !positions
|| count
< 2 ||
1732 positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)
1734 return InvalidParameter
;
1737 new_color
= GdipAlloc(count
* sizeof(ARGB
));
1738 new_pos
= GdipAlloc(count
* sizeof(REAL
));
1739 if (!new_color
|| !new_pos
)
1741 GdipFree(new_color
);
1746 memcpy(new_color
, blend
, sizeof(ARGB
) * count
);
1747 memcpy(new_pos
, positions
, sizeof(REAL
) * count
);
1749 GdipFree(brush
->pblendcolor
);
1750 GdipFree(brush
->pblendpos
);
1752 brush
->pblendcolor
= new_color
;
1753 brush
->pblendpos
= new_pos
;
1754 brush
->pblendcount
= count
;
1759 GpStatus WINGDIPAPI
GdipGetLinePresetBlend(GpLineGradient
*brush
,
1760 ARGB
*blend
, REAL
* positions
, INT count
)
1762 if (!brush
|| !blend
|| !positions
|| count
< 2)
1763 return InvalidParameter
;
1765 if (brush
->pblendcount
== 0)
1766 return GenericError
;
1768 if (count
< brush
->pblendcount
)
1769 return InsufficientBuffer
;
1771 memcpy(blend
, brush
->pblendcolor
, sizeof(ARGB
) * brush
->pblendcount
);
1772 memcpy(positions
, brush
->pblendpos
, sizeof(REAL
) * brush
->pblendcount
);
1777 GpStatus WINGDIPAPI
GdipGetLinePresetBlendCount(GpLineGradient
*brush
,
1780 if (!brush
|| !count
)
1781 return InvalidParameter
;
1783 *count
= brush
->pblendcount
;
1788 GpStatus WINGDIPAPI
GdipResetLineTransform(GpLineGradient
*brush
)
1792 TRACE("(%p)\n", brush
);
1795 FIXME("not implemented\n");
1797 return NotImplemented
;
1800 GpStatus WINGDIPAPI
GdipSetLineTransform(GpLineGradient
*brush
,
1801 GDIPCONST GpMatrix
*matrix
)
1805 TRACE("(%p,%p)\n", brush
, matrix
);
1808 FIXME("not implemented\n");
1810 return NotImplemented
;
1813 GpStatus WINGDIPAPI
GdipGetLineTransform(GpLineGradient
*brush
, GpMatrix
*matrix
)
1817 TRACE("(%p,%p)\n", brush
, matrix
);
1820 FIXME("not implemented\n");
1822 return NotImplemented
;
1825 GpStatus WINGDIPAPI
GdipScaleLineTransform(GpLineGradient
*brush
, REAL sx
, REAL sy
,
1826 GpMatrixOrder order
)
1830 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush
, sx
, sy
, order
);
1833 FIXME("not implemented\n");
1835 return NotImplemented
;
1838 GpStatus WINGDIPAPI
GdipMultiplyLineTransform(GpLineGradient
*brush
,
1839 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1843 TRACE("(%p,%p,%u)\n", brush
, matrix
, order
);
1846 FIXME("not implemented\n");
1848 return NotImplemented
;
1851 GpStatus WINGDIPAPI
GdipTranslateLineTransform(GpLineGradient
* brush
,
1852 REAL dx
, REAL dy
, GpMatrixOrder order
)
1856 TRACE("(%p,%f,%f,%d)\n", brush
, dx
, dy
, order
);
1859 FIXME("not implemented\n");
1864 /******************************************************************************
1865 * GdipTranslateTextureTransform [GDIPLUS.@]
1867 GpStatus WINGDIPAPI
GdipTranslateTextureTransform(GpTexture
* brush
, REAL dx
, REAL dy
,
1868 GpMatrixOrder order
)
1870 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, dx
, dy
, order
);
1873 return InvalidParameter
;
1875 return GdipTranslateMatrix(brush
->transform
, dx
, dy
, order
);
1878 GpStatus WINGDIPAPI
GdipGetLineRect(GpLineGradient
*brush
, GpRectF
*rect
)
1880 TRACE("(%p, %p)\n", brush
, rect
);
1883 return InvalidParameter
;
1885 *rect
= brush
->rect
;
1890 GpStatus WINGDIPAPI
GdipGetLineRectI(GpLineGradient
*brush
, GpRect
*rect
)
1895 TRACE("(%p, %p)\n", brush
, rect
);
1898 return InvalidParameter
;
1900 ret
= GdipGetLineRect(brush
, &rectF
);
1903 rect
->X
= roundr(rectF
.X
);
1904 rect
->Y
= roundr(rectF
.Y
);
1905 rect
->Width
= roundr(rectF
.Width
);
1906 rect
->Height
= roundr(rectF
.Height
);
1912 GpStatus WINGDIPAPI
GdipRotateLineTransform(GpLineGradient
* brush
,
1913 REAL angle
, GpMatrixOrder order
)
1917 TRACE("(%p,%0.2f,%u)\n", brush
, angle
, order
);
1920 return InvalidParameter
;
1923 FIXME("(%p, %.2f, %d) stub\n", brush
, angle
, order
);
1925 return NotImplemented
;