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
GdipGetPathGradientPointCount(GpPathGradient
*grad
,
1025 TRACE("(%p, %p)\n", grad
, count
);
1028 return InvalidParameter
;
1030 *count
= grad
->path
->pathdata
.Count
;
1035 GpStatus WINGDIPAPI
GdipGetPathGradientRect(GpPathGradient
*brush
, GpRectF
*rect
)
1039 TRACE("(%p, %p)\n", brush
, rect
);
1042 return InvalidParameter
;
1044 stat
= GdipGetPathWorldBounds(brush
->path
, rect
, NULL
, NULL
);
1049 GpStatus WINGDIPAPI
GdipGetPathGradientRectI(GpPathGradient
*brush
, GpRect
*rect
)
1054 TRACE("(%p, %p)\n", brush
, rect
);
1057 return InvalidParameter
;
1059 stat
= GdipGetPathGradientRect(brush
, &rectf
);
1060 if(stat
!= Ok
) return stat
;
1062 rect
->X
= roundr(rectf
.X
);
1063 rect
->Y
= roundr(rectf
.Y
);
1064 rect
->Width
= roundr(rectf
.Width
);
1065 rect
->Height
= roundr(rectf
.Height
);
1070 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
1071 *grad
, ARGB
*argb
, INT
*count
)
1075 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1077 if(!grad
|| !argb
|| !count
|| (*count
< grad
->path
->pathdata
.Count
))
1078 return InvalidParameter
;
1081 FIXME("not implemented\n");
1083 return NotImplemented
;
1086 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorCount(GpPathGradient
*brush
, INT
*count
)
1090 TRACE("(%p, %p)\n", brush
, count
);
1092 if (!brush
|| !count
)
1093 return InvalidParameter
;
1096 FIXME("not implemented\n");
1098 return NotImplemented
;
1101 GpStatus WINGDIPAPI
GdipGetPathGradientWrapMode(GpPathGradient
*brush
,
1102 GpWrapMode
*wrapmode
)
1104 TRACE("(%p, %p)\n", brush
, wrapmode
);
1106 if(!brush
|| !wrapmode
)
1107 return InvalidParameter
;
1109 *wrapmode
= brush
->wrap
;
1114 GpStatus WINGDIPAPI
GdipGetSolidFillColor(GpSolidFill
*sf
, ARGB
*argb
)
1116 TRACE("(%p, %p)\n", sf
, argb
);
1119 return InvalidParameter
;
1126 /******************************************************************************
1127 * GdipGetTextureImage [GDIPLUS.@]
1129 GpStatus WINGDIPAPI
GdipGetTextureImage(GpTexture
*brush
, GpImage
**image
)
1131 TRACE("(%p, %p)\n", brush
, image
);
1133 if(!brush
|| !image
)
1134 return InvalidParameter
;
1136 return GdipCloneImage(brush
->image
, image
);
1139 /******************************************************************************
1140 * GdipGetTextureTransform [GDIPLUS.@]
1142 GpStatus WINGDIPAPI
GdipGetTextureTransform(GpTexture
*brush
, GpMatrix
*matrix
)
1144 TRACE("(%p, %p)\n", brush
, matrix
);
1146 if(!brush
|| !matrix
)
1147 return InvalidParameter
;
1149 memcpy(matrix
, brush
->transform
, sizeof(GpMatrix
));
1154 /******************************************************************************
1155 * GdipGetTextureWrapMode [GDIPLUS.@]
1157 GpStatus WINGDIPAPI
GdipGetTextureWrapMode(GpTexture
*brush
, GpWrapMode
*wrapmode
)
1159 TRACE("(%p, %p)\n", brush
, wrapmode
);
1161 if(!brush
|| !wrapmode
)
1162 return InvalidParameter
;
1164 *wrapmode
= brush
->imageattributes
->wrap
;
1169 /******************************************************************************
1170 * GdipMultiplyTextureTransform [GDIPLUS.@]
1172 GpStatus WINGDIPAPI
GdipMultiplyTextureTransform(GpTexture
* brush
,
1173 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1175 TRACE("(%p, %p, %d)\n", brush
, matrix
, order
);
1177 if(!brush
|| !matrix
)
1178 return InvalidParameter
;
1180 return GdipMultiplyMatrix(brush
->transform
, matrix
, order
);
1183 /******************************************************************************
1184 * GdipResetTextureTransform [GDIPLUS.@]
1186 GpStatus WINGDIPAPI
GdipResetTextureTransform(GpTexture
* brush
)
1188 TRACE("(%p)\n", brush
);
1191 return InvalidParameter
;
1193 return GdipSetMatrixElements(brush
->transform
, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1196 /******************************************************************************
1197 * GdipScaleTextureTransform [GDIPLUS.@]
1199 GpStatus WINGDIPAPI
GdipScaleTextureTransform(GpTexture
* brush
,
1200 REAL sx
, REAL sy
, GpMatrixOrder order
)
1202 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, sx
, sy
, order
);
1205 return InvalidParameter
;
1207 return GdipScaleMatrix(brush
->transform
, sx
, sy
, order
);
1210 GpStatus WINGDIPAPI
GdipSetLineBlend(GpLineGradient
*brush
,
1211 GDIPCONST REAL
*factors
, GDIPCONST REAL
* positions
, INT count
)
1213 REAL
*new_blendfac
, *new_blendpos
;
1215 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1217 if(!brush
|| !factors
|| !positions
|| count
<= 0 ||
1218 (count
>= 2 && (positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)))
1219 return InvalidParameter
;
1221 new_blendfac
= GdipAlloc(count
* sizeof(REAL
));
1222 new_blendpos
= GdipAlloc(count
* sizeof(REAL
));
1224 if (!new_blendfac
|| !new_blendpos
)
1226 GdipFree(new_blendfac
);
1227 GdipFree(new_blendpos
);
1231 memcpy(new_blendfac
, factors
, count
* sizeof(REAL
));
1232 memcpy(new_blendpos
, positions
, count
* sizeof(REAL
));
1234 GdipFree(brush
->blendfac
);
1235 GdipFree(brush
->blendpos
);
1237 brush
->blendcount
= count
;
1238 brush
->blendfac
= new_blendfac
;
1239 brush
->blendpos
= new_blendpos
;
1244 GpStatus WINGDIPAPI
GdipGetLineBlend(GpLineGradient
*brush
, REAL
*factors
,
1245 REAL
*positions
, INT count
)
1247 TRACE("(%p, %p, %p, %i)\n", brush
, factors
, positions
, count
);
1249 if (!brush
|| !factors
|| !positions
|| count
<= 0)
1250 return InvalidParameter
;
1252 if (count
< brush
->blendcount
)
1253 return InsufficientBuffer
;
1255 memcpy(factors
, brush
->blendfac
, brush
->blendcount
* sizeof(REAL
));
1256 memcpy(positions
, brush
->blendpos
, brush
->blendcount
* sizeof(REAL
));
1261 GpStatus WINGDIPAPI
GdipGetLineBlendCount(GpLineGradient
*brush
, INT
*count
)
1263 TRACE("(%p, %p)\n", brush
, count
);
1265 if (!brush
|| !count
)
1266 return InvalidParameter
;
1268 *count
= brush
->blendcount
;
1273 GpStatus WINGDIPAPI
GdipSetLineGammaCorrection(GpLineGradient
*line
,
1276 TRACE("(%p, %d)\n", line
, usegamma
);
1279 return InvalidParameter
;
1281 line
->gamma
= usegamma
;
1286 GpStatus WINGDIPAPI
GdipSetLineSigmaBlend(GpLineGradient
*line
, REAL focus
,
1293 const int precision
= 16;
1294 REAL erf_range
; /* we use values erf(-erf_range) through erf(+erf_range) */
1298 TRACE("(%p, %0.2f, %0.2f)\n", line
, focus
, scale
);
1300 if(!line
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1301 return InvalidParameter
;
1303 /* we want 2 standard deviations */
1304 erf_range
= 2.0 / sqrt(2);
1306 /* calculate the constants we need to normalize the error function to be
1307 between 0.0 and scale over the range we need */
1308 min_erf
= erf(-erf_range
);
1309 scale_erf
= scale
/ (-2.0 * min_erf
);
1315 for (i
=1; i
<precision
; i
++)
1317 positions
[i
] = focus
* i
/ precision
;
1318 factors
[i
] = scale_erf
* (erf(2 * erf_range
* i
/ precision
- erf_range
) - min_erf
);
1320 num_points
+= precision
;
1323 positions
[num_points
] = focus
;
1324 factors
[num_points
] = scale
;
1329 for (i
=1; i
<precision
; i
++)
1331 positions
[i
+num_points
-1] = (focus
+ ((1.0-focus
) * i
/ precision
));
1332 factors
[i
+num_points
-1] = scale_erf
* (erf(erf_range
- 2 * erf_range
* i
/ precision
) - min_erf
);
1334 num_points
+= precision
;
1335 positions
[num_points
-1] = 1.0;
1336 factors
[num_points
-1] = 0.0;
1339 return GdipSetLineBlend(line
, factors
, positions
, num_points
);
1342 GpStatus WINGDIPAPI
GdipSetLineWrapMode(GpLineGradient
*line
,
1345 TRACE("(%p, %d)\n", line
, wrap
);
1347 if(!line
|| wrap
== WrapModeClamp
)
1348 return InvalidParameter
;
1355 GpStatus WINGDIPAPI
GdipSetPathGradientBlend(GpPathGradient
*brush
, GDIPCONST REAL
*blend
,
1356 GDIPCONST REAL
*pos
, INT count
)
1360 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, pos
, count
);
1363 FIXME("not implemented\n");
1365 return NotImplemented
;
1368 GpStatus WINGDIPAPI
GdipSetPathGradientLinearBlend(GpPathGradient
*brush
,
1369 REAL focus
, REAL scale
)
1373 TRACE("(%p,%0.2f,%0.2f)\n", brush
, focus
, scale
);
1376 FIXME("not implemented\n");
1378 return NotImplemented
;
1381 GpStatus WINGDIPAPI
GdipSetPathGradientPresetBlend(GpPathGradient
*brush
,
1382 GDIPCONST ARGB
*blend
, GDIPCONST REAL
*pos
, INT count
)
1384 FIXME("(%p,%p,%p,%i): stub\n", brush
, blend
, pos
, count
);
1385 return NotImplemented
;
1388 GpStatus WINGDIPAPI
GdipGetPathGradientPresetBlend(GpPathGradient
*brush
,
1389 ARGB
*blend
, REAL
*pos
, INT count
)
1391 FIXME("(%p,%p,%p,%i): stub\n", brush
, blend
, pos
, count
);
1392 return NotImplemented
;
1395 GpStatus WINGDIPAPI
GdipGetPathGradientPresetBlendCount(GpPathGradient
*brush
,
1398 FIXME("(%p,%p): stub\n", brush
, count
);
1399 return NotImplemented
;
1402 GpStatus WINGDIPAPI
GdipSetPathGradientCenterColor(GpPathGradient
*grad
,
1405 TRACE("(%p, %x)\n", grad
, argb
);
1408 return InvalidParameter
;
1410 grad
->centercolor
= argb
;
1414 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPoint(GpPathGradient
*grad
,
1417 TRACE("(%p, %s)\n", grad
, debugstr_pointf(point
));
1420 return InvalidParameter
;
1422 grad
->center
.X
= point
->X
;
1423 grad
->center
.Y
= point
->Y
;
1428 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPointI(GpPathGradient
*grad
,
1433 TRACE("(%p, %p)\n", grad
, point
);
1436 return InvalidParameter
;
1438 ptf
.X
= (REAL
)point
->X
;
1439 ptf
.Y
= (REAL
)point
->Y
;
1441 return GdipSetPathGradientCenterPoint(grad
,&ptf
);
1444 GpStatus WINGDIPAPI
GdipSetPathGradientFocusScales(GpPathGradient
*grad
,
1447 TRACE("(%p, %.2f, %.2f)\n", grad
, x
, y
);
1450 return InvalidParameter
;
1458 GpStatus WINGDIPAPI
GdipSetPathGradientGammaCorrection(GpPathGradient
*grad
,
1461 TRACE("(%p, %d)\n", grad
, gamma
);
1464 return InvalidParameter
;
1466 grad
->gamma
= gamma
;
1471 GpStatus WINGDIPAPI
GdipSetPathGradientSigmaBlend(GpPathGradient
*grad
,
1472 REAL focus
, REAL scale
)
1476 TRACE("(%p,%0.2f,%0.2f)\n", grad
, focus
, scale
);
1478 if(!grad
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
1479 return InvalidParameter
;
1482 FIXME("not implemented\n");
1484 return NotImplemented
;
1487 GpStatus WINGDIPAPI
GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
1488 *grad
, GDIPCONST ARGB
*argb
, INT
*count
)
1492 TRACE("(%p,%p,%p)\n", grad
, argb
, count
);
1494 if(!grad
|| !argb
|| !count
|| (*count
<= 0) ||
1495 (*count
> grad
->path
->pathdata
.Count
))
1496 return InvalidParameter
;
1499 FIXME("not implemented\n");
1501 return NotImplemented
;
1504 GpStatus WINGDIPAPI
GdipSetPathGradientWrapMode(GpPathGradient
*grad
,
1507 TRACE("(%p, %d)\n", grad
, wrap
);
1510 return InvalidParameter
;
1517 GpStatus WINGDIPAPI
GdipSetPathGradientTransform(GpPathGradient
*grad
,
1522 TRACE("(%p,%p)\n", grad
, matrix
);
1525 FIXME("not implemented\n");
1527 return NotImplemented
;
1530 GpStatus WINGDIPAPI
GdipGetPathGradientTransform(GpPathGradient
*grad
,
1535 TRACE("(%p,%p)\n", grad
, matrix
);
1538 FIXME("not implemented\n");
1540 return NotImplemented
;
1543 GpStatus WINGDIPAPI
GdipMultiplyPathGradientTransform(GpPathGradient
*grad
,
1544 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1548 TRACE("(%p,%p,%i)\n", grad
, matrix
, order
);
1551 FIXME("not implemented\n");
1553 return NotImplemented
;
1556 GpStatus WINGDIPAPI
GdipRotatePathGradientTransform(GpPathGradient
*grad
,
1557 REAL angle
, GpMatrixOrder order
)
1561 TRACE("(%p,%0.2f,%i)\n", grad
, angle
, order
);
1564 FIXME("not implemented\n");
1566 return NotImplemented
;
1569 GpStatus WINGDIPAPI
GdipScalePathGradientTransform(GpPathGradient
*grad
,
1570 REAL sx
, REAL sy
, GpMatrixOrder order
)
1574 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad
, sx
, sy
, order
);
1577 FIXME("not implemented\n");
1579 return NotImplemented
;
1582 GpStatus WINGDIPAPI
GdipTranslatePathGradientTransform(GpPathGradient
*grad
,
1583 REAL dx
, REAL dy
, GpMatrixOrder order
)
1587 TRACE("(%p,%0.2f,%0.2f,%i)\n", grad
, dx
, dy
, order
);
1590 FIXME("not implemented\n");
1592 return NotImplemented
;
1595 GpStatus WINGDIPAPI
GdipSetSolidFillColor(GpSolidFill
*sf
, ARGB argb
)
1597 TRACE("(%p, %x)\n", sf
, argb
);
1600 return InvalidParameter
;
1606 /******************************************************************************
1607 * GdipSetTextureTransform [GDIPLUS.@]
1609 GpStatus WINGDIPAPI
GdipSetTextureTransform(GpTexture
*texture
,
1610 GDIPCONST GpMatrix
*matrix
)
1612 TRACE("(%p, %p)\n", texture
, matrix
);
1614 if(!texture
|| !matrix
)
1615 return InvalidParameter
;
1617 memcpy(texture
->transform
, matrix
, sizeof(GpMatrix
));
1622 /******************************************************************************
1623 * GdipSetTextureWrapMode [GDIPLUS.@]
1625 * WrapMode not used, only stored
1627 GpStatus WINGDIPAPI
GdipSetTextureWrapMode(GpTexture
*brush
, GpWrapMode wrapmode
)
1629 TRACE("(%p, %d)\n", brush
, wrapmode
);
1632 return InvalidParameter
;
1634 brush
->imageattributes
->wrap
= wrapmode
;
1639 GpStatus WINGDIPAPI
GdipSetLineColors(GpLineGradient
*brush
, ARGB color1
,
1642 TRACE("(%p, %x, %x)\n", brush
, color1
, color2
);
1645 return InvalidParameter
;
1647 brush
->startcolor
= color1
;
1648 brush
->endcolor
= color2
;
1653 GpStatus WINGDIPAPI
GdipGetLineColors(GpLineGradient
*brush
, ARGB
*colors
)
1655 TRACE("(%p, %p)\n", brush
, colors
);
1657 if(!brush
|| !colors
)
1658 return InvalidParameter
;
1660 colors
[0] = brush
->startcolor
;
1661 colors
[1] = brush
->endcolor
;
1666 /******************************************************************************
1667 * GdipRotateTextureTransform [GDIPLUS.@]
1669 GpStatus WINGDIPAPI
GdipRotateTextureTransform(GpTexture
* brush
, REAL angle
,
1670 GpMatrixOrder order
)
1672 TRACE("(%p, %.2f, %d)\n", brush
, angle
, order
);
1675 return InvalidParameter
;
1677 return GdipRotateMatrix(brush
->transform
, angle
, order
);
1680 GpStatus WINGDIPAPI
GdipSetLineLinearBlend(GpLineGradient
*brush
, REAL focus
,
1687 TRACE("(%p,%.2f,%.2f)\n", brush
, focus
, scale
);
1689 if (!brush
) return InvalidParameter
;
1693 factors
[num_points
] = 0.0;
1694 positions
[num_points
] = 0.0;
1698 factors
[num_points
] = scale
;
1699 positions
[num_points
] = focus
;
1704 factors
[num_points
] = 0.0;
1705 positions
[num_points
] = 1.0;
1709 return GdipSetLineBlend(brush
, factors
, positions
, num_points
);
1712 GpStatus WINGDIPAPI
GdipSetLinePresetBlend(GpLineGradient
*brush
,
1713 GDIPCONST ARGB
*blend
, GDIPCONST REAL
* positions
, INT count
)
1717 TRACE("(%p,%p,%p,%i)\n", brush
, blend
, positions
, count
);
1719 if (!brush
|| !blend
|| !positions
|| count
< 2 ||
1720 positions
[0] != 0.0f
|| positions
[count
-1] != 1.0f
)
1722 return InvalidParameter
;
1725 new_color
= GdipAlloc(count
* sizeof(ARGB
));
1726 new_pos
= GdipAlloc(count
* sizeof(REAL
));
1727 if (!new_color
|| !new_pos
)
1729 GdipFree(new_color
);
1734 memcpy(new_color
, blend
, sizeof(ARGB
) * count
);
1735 memcpy(new_pos
, positions
, sizeof(REAL
) * count
);
1737 GdipFree(brush
->pblendcolor
);
1738 GdipFree(brush
->pblendpos
);
1740 brush
->pblendcolor
= new_color
;
1741 brush
->pblendpos
= new_pos
;
1742 brush
->pblendcount
= count
;
1747 GpStatus WINGDIPAPI
GdipGetLinePresetBlend(GpLineGradient
*brush
,
1748 ARGB
*blend
, REAL
* positions
, INT count
)
1750 if (!brush
|| !blend
|| !positions
|| count
< 2)
1751 return InvalidParameter
;
1753 if (brush
->pblendcount
== 0)
1754 return GenericError
;
1756 if (count
< brush
->pblendcount
)
1757 return InsufficientBuffer
;
1759 memcpy(blend
, brush
->pblendcolor
, sizeof(ARGB
) * brush
->pblendcount
);
1760 memcpy(positions
, brush
->pblendpos
, sizeof(REAL
) * brush
->pblendcount
);
1765 GpStatus WINGDIPAPI
GdipGetLinePresetBlendCount(GpLineGradient
*brush
,
1768 if (!brush
|| !count
)
1769 return InvalidParameter
;
1771 *count
= brush
->pblendcount
;
1776 GpStatus WINGDIPAPI
GdipResetLineTransform(GpLineGradient
*brush
)
1780 TRACE("(%p)\n", brush
);
1783 FIXME("not implemented\n");
1785 return NotImplemented
;
1788 GpStatus WINGDIPAPI
GdipSetLineTransform(GpLineGradient
*brush
,
1789 GDIPCONST GpMatrix
*matrix
)
1793 TRACE("(%p,%p)\n", brush
, matrix
);
1796 FIXME("not implemented\n");
1798 return NotImplemented
;
1801 GpStatus WINGDIPAPI
GdipGetLineTransform(GpLineGradient
*brush
, GpMatrix
*matrix
)
1805 TRACE("(%p,%p)\n", brush
, matrix
);
1808 FIXME("not implemented\n");
1810 return NotImplemented
;
1813 GpStatus WINGDIPAPI
GdipScaleLineTransform(GpLineGradient
*brush
, REAL sx
, REAL sy
,
1814 GpMatrixOrder order
)
1818 TRACE("(%p,%0.2f,%0.2f,%u)\n", brush
, sx
, sy
, order
);
1821 FIXME("not implemented\n");
1823 return NotImplemented
;
1826 GpStatus WINGDIPAPI
GdipMultiplyLineTransform(GpLineGradient
*brush
,
1827 GDIPCONST GpMatrix
*matrix
, GpMatrixOrder order
)
1831 TRACE("(%p,%p,%u)\n", brush
, matrix
, order
);
1834 FIXME("not implemented\n");
1836 return NotImplemented
;
1839 GpStatus WINGDIPAPI
GdipTranslateLineTransform(GpLineGradient
* brush
,
1840 REAL dx
, REAL dy
, GpMatrixOrder order
)
1844 TRACE("(%p,%f,%f,%d)\n", brush
, dx
, dy
, order
);
1847 FIXME("not implemented\n");
1852 /******************************************************************************
1853 * GdipTranslateTextureTransform [GDIPLUS.@]
1855 GpStatus WINGDIPAPI
GdipTranslateTextureTransform(GpTexture
* brush
, REAL dx
, REAL dy
,
1856 GpMatrixOrder order
)
1858 TRACE("(%p, %.2f, %.2f, %d)\n", brush
, dx
, dy
, order
);
1861 return InvalidParameter
;
1863 return GdipTranslateMatrix(brush
->transform
, dx
, dy
, order
);
1866 GpStatus WINGDIPAPI
GdipGetLineRect(GpLineGradient
*brush
, GpRectF
*rect
)
1868 TRACE("(%p, %p)\n", brush
, rect
);
1871 return InvalidParameter
;
1873 *rect
= brush
->rect
;
1878 GpStatus WINGDIPAPI
GdipGetLineRectI(GpLineGradient
*brush
, GpRect
*rect
)
1883 TRACE("(%p, %p)\n", brush
, rect
);
1886 return InvalidParameter
;
1888 ret
= GdipGetLineRect(brush
, &rectF
);
1891 rect
->X
= roundr(rectF
.X
);
1892 rect
->Y
= roundr(rectF
.Y
);
1893 rect
->Width
= roundr(rectF
.Width
);
1894 rect
->Height
= roundr(rectF
.Height
);
1900 GpStatus WINGDIPAPI
GdipRotateLineTransform(GpLineGradient
* brush
,
1901 REAL angle
, GpMatrixOrder order
)
1905 TRACE("(%p,%0.2f,%u)\n", brush
, angle
, order
);
1908 return InvalidParameter
;
1911 FIXME("(%p, %.2f, %d) stub\n", brush
, angle
, order
);
1913 return NotImplemented
;