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 GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
81 GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
82 GpWrapMode wrap, GpLineGradient **line)
84 COLORREF col = ARGB2COLORREF(startcolor);
86 if(!line || !startpoint || !endpoint || wrap == WrapModeClamp)
87 return InvalidParameter;
89 *line = GdipAlloc(sizeof(GpLineGradient));
90 if(!*line) return OutOfMemory;
92 (*line)->brush.lb.lbStyle = BS_SOLID;
93 (*line)->brush.lb.lbColor = col;
94 (*line)->brush.lb.lbHatch = 0;
95 (*line)->brush.gdibrush = CreateSolidBrush(col);
96 (*line)->brush.bt = BrushTypeLinearGradient;
98 (*line)->startpoint.X = startpoint->X;
99 (*line)->startpoint.Y = startpoint->Y;
100 (*line)->endpoint.X = endpoint->X;
101 (*line)->endpoint.Y = endpoint->Y;
102 (*line)->startcolor = startcolor;
103 (*line)->endcolor = endcolor;
104 (*line)->wrap = wrap;
109 GpStatus WINGDIPAPI GdipCreatePathGradient(GDIPCONST GpPointF* points,
110 INT count, GpWrapMode wrap, GpPathGradient **grad)
112 COLORREF col = ARGB2COLORREF(0xffffffff);
115 return InvalidParameter;
120 *grad = GdipAlloc(sizeof(GpPathGradient));
121 if (!*grad) return OutOfMemory;
123 (*grad)->pathdata.Count = count;
124 (*grad)->pathdata.Points = GdipAlloc(count * sizeof(PointF));
125 (*grad)->pathdata.Types = GdipAlloc(count);
127 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
128 GdipFree((*grad)->pathdata.Points);
129 GdipFree((*grad)->pathdata.Types);
134 memcpy((*grad)->pathdata.Points, points, count * sizeof(PointF));
135 memset((*grad)->pathdata.Types, PathPointTypeLine, count);
137 (*grad)->brush.lb.lbStyle = BS_SOLID;
138 (*grad)->brush.lb.lbColor = col;
139 (*grad)->brush.lb.lbHatch = 0;
141 (*grad)->brush.gdibrush = CreateSolidBrush(col);
142 (*grad)->brush.bt = BrushTypePathGradient;
143 (*grad)->centercolor = 0xffffffff;
144 (*grad)->wrap = wrap;
145 (*grad)->gamma = FALSE;
146 (*grad)->center.X = 0.0;
147 (*grad)->center.Y = 0.0;
148 (*grad)->focus.X = 0.0;
149 (*grad)->focus.Y = 0.0;
154 /* FIXME: path gradient brushes not truly supported (drawn as solid brushes) */
155 GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
156 GpPathGradient **grad)
158 COLORREF col = ARGB2COLORREF(0xffffffff);
161 return InvalidParameter;
163 *grad = GdipAlloc(sizeof(GpPathGradient));
164 if (!*grad) return OutOfMemory;
166 (*grad)->pathdata.Count = path->pathdata.Count;
167 (*grad)->pathdata.Points = GdipAlloc(path->pathdata.Count * sizeof(PointF));
168 (*grad)->pathdata.Types = GdipAlloc(path->pathdata.Count);
170 if(!(*grad)->pathdata.Points || !(*grad)->pathdata.Types){
171 GdipFree((*grad)->pathdata.Points);
172 GdipFree((*grad)->pathdata.Types);
177 memcpy((*grad)->pathdata.Points, path->pathdata.Points,
178 path->pathdata.Count * sizeof(PointF));
179 memcpy((*grad)->pathdata.Types, path->pathdata.Types, path->pathdata.Count);
181 (*grad)->brush.lb.lbStyle = BS_SOLID;
182 (*grad)->brush.lb.lbColor = col;
183 (*grad)->brush.lb.lbHatch = 0;
185 (*grad)->brush.gdibrush = CreateSolidBrush(col);
186 (*grad)->brush.bt = BrushTypePathGradient;
187 (*grad)->centercolor = 0xffffffff;
188 (*grad)->wrap = WrapModeClamp;
189 (*grad)->gamma = FALSE;
190 /* FIXME: this should be set to the "centroid" of the path by default */
191 (*grad)->center.X = 0.0;
192 (*grad)->center.Y = 0.0;
193 (*grad)->focus.X = 0.0;
194 (*grad)->focus.Y = 0.0;
199 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
201 COLORREF col = ARGB2COLORREF(color);
203 if(!sf) return InvalidParameter;
205 *sf = GdipAlloc(sizeof(GpSolidFill));
206 if (!*sf) return OutOfMemory;
208 (*sf)->brush.lb.lbStyle = BS_SOLID;
209 (*sf)->brush.lb.lbColor = col;
210 (*sf)->brush.lb.lbHatch = 0;
212 (*sf)->brush.gdibrush = CreateSolidBrush(col);
213 (*sf)->brush.bt = BrushTypeSolidColor;
214 (*sf)->color = color;
219 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
221 if(!brush || !type) return InvalidParameter;
228 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
230 if(!brush) return InvalidParameter;
234 case BrushTypePathGradient:
235 GdipFree(((GpPathGradient*) brush)->pathdata.Points);
236 GdipFree(((GpPathGradient*) brush)->pathdata.Types);
238 case BrushTypeSolidColor:
243 DeleteObject(brush->gdibrush);
249 GpStatus WINGDIPAPI GdipGetPathGradientCenterPoint(GpPathGradient *grad,
253 return InvalidParameter;
255 point->X = grad->center.X;
256 point->Y = grad->center.Y;
261 GpStatus WINGDIPAPI GdipGetPathGradientFocusScales(GpPathGradient *grad,
264 if(!grad || !x || !y)
265 return InvalidParameter;
273 GpStatus WINGDIPAPI GdipGetPathGradientGammaCorrection(GpPathGradient *grad,
277 return InvalidParameter;
279 *gamma = grad->gamma;
284 GpStatus WINGDIPAPI GdipGetPathGradientPointCount(GpPathGradient *grad,
288 return InvalidParameter;
290 *count = grad->pathdata.Count;
295 GpStatus WINGDIPAPI GdipGetPathGradientSurroundColorsWithCount(GpPathGradient
296 *grad, ARGB *argb, INT *count)
300 if(!grad || !argb || !count || (*count < grad->pathdata.Count))
301 return InvalidParameter;
304 FIXME("not implemented\n");
306 return NotImplemented;
309 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
312 return InvalidParameter;
319 GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
322 if(!line || wrap == WrapModeClamp)
323 return InvalidParameter;
330 GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
334 return InvalidParameter;
336 grad->centercolor = argb;
337 grad->brush.lb.lbColor = ARGB2COLORREF(argb);
339 DeleteObject(grad->brush.gdibrush);
340 grad->brush.gdibrush = CreateSolidBrush(grad->brush.lb.lbColor);
345 GpStatus WINGDIPAPI GdipSetPathGradientCenterPoint(GpPathGradient *grad,
349 return InvalidParameter;
351 grad->center.X = point->X;
352 grad->center.Y = point->Y;
357 GpStatus WINGDIPAPI GdipSetPathGradientFocusScales(GpPathGradient *grad,
361 return InvalidParameter;
369 GpStatus WINGDIPAPI GdipSetPathGradientGammaCorrection(GpPathGradient *grad,
373 return InvalidParameter;
380 GpStatus WINGDIPAPI GdipSetPathGradientSigmaBlend(GpPathGradient *grad,
381 REAL focus, REAL scale)
385 if(!grad || focus < 0.0 || focus > 1.0 || scale < 0.0 || scale > 1.0)
386 return InvalidParameter;
389 FIXME("not implemented\n");
391 return NotImplemented;
394 GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
395 *grad, ARGB *argb, INT *count)
399 if(!grad || !argb || !count || (*count <= 0) ||
400 (*count > grad->pathdata.Count))
401 return InvalidParameter;
404 FIXME("not implemented\n");
406 return NotImplemented;
409 GpStatus WINGDIPAPI GdipSetPathGradientWrapMode(GpPathGradient *grad,
413 return InvalidParameter;
420 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
423 return InvalidParameter;
426 sf->brush.lb.lbColor = ARGB2COLORREF(argb);
428 DeleteObject(sf->brush.gdibrush);
429 sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);