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
25 #include "gdiplus_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus
);
30 GpStatus WINGDIPAPI
GdipCloneBrush(GpBrush
*brush
, GpBrush
**clone
)
33 return InvalidParameter
;
36 case BrushTypeSolidColor
:
37 *clone
= GdipAlloc(sizeof(GpSolidFill
));
38 if (!*clone
) return OutOfMemory
;
40 memcpy(*clone
, brush
, sizeof(GpSolidFill
));
42 (*clone
)->gdibrush
= CreateBrushIndirect(&(*clone
)->lb
);
44 case BrushTypePathGradient
:{
45 GpPathGradient
*src
, *dest
;
48 *clone
= GdipAlloc(sizeof(GpPathGradient
));
49 if (!*clone
) return OutOfMemory
;
51 src
= (GpPathGradient
*) brush
,
52 dest
= (GpPathGradient
*) *clone
;
53 count
= src
->pathdata
.Count
;
55 memcpy(dest
, src
, sizeof(GpPathGradient
));
57 dest
->pathdata
.Count
= count
;
58 dest
->pathdata
.Points
= GdipAlloc(count
* sizeof(PointF
));
59 dest
->pathdata
.Types
= GdipAlloc(count
);
61 if(!dest
->pathdata
.Points
|| !dest
->pathdata
.Types
){
62 GdipFree(dest
->pathdata
.Points
);
63 GdipFree(dest
->pathdata
.Types
);
68 memcpy(dest
->pathdata
.Points
, src
->pathdata
.Points
, count
* sizeof(PointF
));
69 memcpy(dest
->pathdata
.Types
, src
->pathdata
.Types
, count
);
74 return NotImplemented
;
80 GpStatus WINGDIPAPI
GdipCreatePathGradient(GDIPCONST GpPointF
* points
,
81 INT count
, GpWrapMode wrap
, GpPathGradient
**grad
)
83 COLORREF col
= ARGB2COLORREF(0xffffffff);
86 return InvalidParameter
;
91 *grad
= GdipAlloc(sizeof(GpPathGradient
));
92 if (!*grad
) return OutOfMemory
;
94 (*grad
)->pathdata
.Count
= count
;
95 (*grad
)->pathdata
.Points
= GdipAlloc(count
* sizeof(PointF
));
96 (*grad
)->pathdata
.Types
= GdipAlloc(count
);
98 if(!(*grad
)->pathdata
.Points
|| !(*grad
)->pathdata
.Types
){
99 GdipFree((*grad
)->pathdata
.Points
);
100 GdipFree((*grad
)->pathdata
.Types
);
105 memcpy((*grad
)->pathdata
.Points
, points
, count
* sizeof(PointF
));
106 memset((*grad
)->pathdata
.Types
, PathPointTypeLine
, count
);
108 (*grad
)->brush
.lb
.lbStyle
= BS_SOLID
;
109 (*grad
)->brush
.lb
.lbColor
= col
;
110 (*grad
)->brush
.lb
.lbHatch
= 0;
112 (*grad
)->brush
.gdibrush
= CreateSolidBrush(col
);
113 (*grad
)->brush
.bt
= BrushTypePathGradient
;
114 (*grad
)->centercolor
= 0xffffffff;
115 (*grad
)->wrap
= wrap
;
116 (*grad
)->gamma
= FALSE
;
117 (*grad
)->center
.X
= 0.0;
118 (*grad
)->center
.Y
= 0.0;
119 (*grad
)->focus
.X
= 0.0;
120 (*grad
)->focus
.Y
= 0.0;
125 /* FIXME: path gradient brushes not truly supported (drawn as solid brushes) */
126 GpStatus WINGDIPAPI
GdipCreatePathGradientFromPath(GDIPCONST GpPath
* path
,
127 GpPathGradient
**grad
)
129 COLORREF col
= ARGB2COLORREF(0xffffffff);
132 return InvalidParameter
;
134 *grad
= GdipAlloc(sizeof(GpPathGradient
));
135 if (!*grad
) return OutOfMemory
;
137 (*grad
)->pathdata
.Count
= path
->pathdata
.Count
;
138 (*grad
)->pathdata
.Points
= GdipAlloc(path
->pathdata
.Count
* sizeof(PointF
));
139 (*grad
)->pathdata
.Types
= GdipAlloc(path
->pathdata
.Count
);
141 if(!(*grad
)->pathdata
.Points
|| !(*grad
)->pathdata
.Types
){
142 GdipFree((*grad
)->pathdata
.Points
);
143 GdipFree((*grad
)->pathdata
.Types
);
148 memcpy((*grad
)->pathdata
.Points
, path
->pathdata
.Points
,
149 path
->pathdata
.Count
* sizeof(PointF
));
150 memcpy((*grad
)->pathdata
.Types
, path
->pathdata
.Types
, path
->pathdata
.Count
);
152 (*grad
)->brush
.lb
.lbStyle
= BS_SOLID
;
153 (*grad
)->brush
.lb
.lbColor
= col
;
154 (*grad
)->brush
.lb
.lbHatch
= 0;
156 (*grad
)->brush
.gdibrush
= CreateSolidBrush(col
);
157 (*grad
)->brush
.bt
= BrushTypePathGradient
;
158 (*grad
)->centercolor
= 0xffffffff;
159 (*grad
)->wrap
= WrapModeClamp
;
160 (*grad
)->gamma
= FALSE
;
161 /* FIXME: this should be set to the "centroid" of the path by default */
162 (*grad
)->center
.X
= 0.0;
163 (*grad
)->center
.Y
= 0.0;
164 (*grad
)->focus
.X
= 0.0;
165 (*grad
)->focus
.Y
= 0.0;
170 GpStatus WINGDIPAPI
GdipCreateSolidFill(ARGB color
, GpSolidFill
**sf
)
172 COLORREF col
= ARGB2COLORREF(color
);
174 if(!sf
) return InvalidParameter
;
176 *sf
= GdipAlloc(sizeof(GpSolidFill
));
177 if (!*sf
) return OutOfMemory
;
179 (*sf
)->brush
.lb
.lbStyle
= BS_SOLID
;
180 (*sf
)->brush
.lb
.lbColor
= col
;
181 (*sf
)->brush
.lb
.lbHatch
= 0;
183 (*sf
)->brush
.gdibrush
= CreateSolidBrush(col
);
184 (*sf
)->brush
.bt
= BrushTypeSolidColor
;
185 (*sf
)->color
= color
;
190 GpStatus WINGDIPAPI
GdipGetBrushType(GpBrush
*brush
, GpBrushType
*type
)
192 if(!brush
|| !type
) return InvalidParameter
;
199 GpStatus WINGDIPAPI
GdipDeleteBrush(GpBrush
*brush
)
201 if(!brush
) return InvalidParameter
;
205 case BrushTypePathGradient
:
206 GdipFree(((GpPathGradient
*) brush
)->pathdata
.Points
);
207 GdipFree(((GpPathGradient
*) brush
)->pathdata
.Types
);
209 case BrushTypeSolidColor
:
214 DeleteObject(brush
->gdibrush
);
220 GpStatus WINGDIPAPI
GdipGetPathGradientCenterPoint(GpPathGradient
*grad
,
224 return InvalidParameter
;
226 point
->X
= grad
->center
.X
;
227 point
->Y
= grad
->center
.Y
;
232 GpStatus WINGDIPAPI
GdipGetPathGradientFocusScales(GpPathGradient
*grad
,
235 if(!grad
|| !x
|| !y
)
236 return InvalidParameter
;
244 GpStatus WINGDIPAPI
GdipGetPathGradientGammaCorrection(GpPathGradient
*grad
,
248 return InvalidParameter
;
250 *gamma
= grad
->gamma
;
255 GpStatus WINGDIPAPI
GdipGetPathGradientPointCount(GpPathGradient
*grad
,
259 return InvalidParameter
;
261 *count
= grad
->pathdata
.Count
;
266 GpStatus WINGDIPAPI
GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
267 *grad
, ARGB
*argb
, INT
*count
)
271 if(!grad
|| !argb
|| !count
|| (*count
< grad
->pathdata
.Count
))
272 return InvalidParameter
;
275 FIXME("not implemented\n");
277 return NotImplemented
;
280 GpStatus WINGDIPAPI
GdipGetSolidFillColor(GpSolidFill
*sf
, ARGB
*argb
)
283 return InvalidParameter
;
290 GpStatus WINGDIPAPI
GdipSetPathGradientCenterColor(GpPathGradient
*grad
,
294 return InvalidParameter
;
296 grad
->centercolor
= argb
;
297 grad
->brush
.lb
.lbColor
= ARGB2COLORREF(argb
);
299 DeleteObject(grad
->brush
.gdibrush
);
300 grad
->brush
.gdibrush
= CreateSolidBrush(grad
->brush
.lb
.lbColor
);
305 GpStatus WINGDIPAPI
GdipSetPathGradientCenterPoint(GpPathGradient
*grad
,
309 return InvalidParameter
;
311 grad
->center
.X
= point
->X
;
312 grad
->center
.Y
= point
->Y
;
317 GpStatus WINGDIPAPI
GdipSetPathGradientFocusScales(GpPathGradient
*grad
,
321 return InvalidParameter
;
329 GpStatus WINGDIPAPI
GdipSetPathGradientGammaCorrection(GpPathGradient
*grad
,
333 return InvalidParameter
;
340 GpStatus WINGDIPAPI
GdipSetPathGradientSigmaBlend(GpPathGradient
*grad
,
341 REAL focus
, REAL scale
)
345 if(!grad
|| focus
< 0.0 || focus
> 1.0 || scale
< 0.0 || scale
> 1.0)
346 return InvalidParameter
;
349 FIXME("not implemented\n");
351 return NotImplemented
;
354 GpStatus WINGDIPAPI
GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
355 *grad
, ARGB
*argb
, INT
*count
)
359 if(!grad
|| !argb
|| !count
|| (*count
<= 0) ||
360 (*count
> grad
->pathdata
.Count
))
361 return InvalidParameter
;
364 FIXME("not implemented\n");
366 return NotImplemented
;
369 GpStatus WINGDIPAPI
GdipSetPathGradientWrapMode(GpPathGradient
*grad
,
373 return InvalidParameter
;
380 GpStatus WINGDIPAPI
GdipSetSolidFillColor(GpSolidFill
*sf
, ARGB argb
)
383 return InvalidParameter
;
386 sf
->brush
.lb
.lbColor
= ARGB2COLORREF(argb
);
388 DeleteObject(sf
->brush
.gdibrush
);
389 sf
->brush
.gdibrush
= CreateSolidBrush(sf
->brush
.lb
.lbColor
);