push b8ecebbd387de253bc88d2c382ef272048a0b089
[wine/hacks.git] / dlls / gdiplus / brush.c
blob76456bd784d08fc138faa9a13a7b153e287d768a
1 /*
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
19 #include "windef.h"
20 #include "wingdi.h"
21 #include "gdiplus.h"
22 #include "gdiplus_private.h"
24 GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
26 if(!brush || !clone)
27 return InvalidParameter;
29 switch(brush->bt){
30 case BrushTypeSolidColor:
31 *clone = GdipAlloc(sizeof(GpSolidFill));
32 if (!*clone) return OutOfMemory;
34 memcpy(*clone, brush, sizeof(GpSolidFill));
36 (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
37 break;
38 default:
39 return NotImplemented;
42 return Ok;
45 GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
47 COLORREF col = ARGB2COLORREF(color);
49 if(!sf) return InvalidParameter;
51 *sf = GdipAlloc(sizeof(GpSolidFill));
52 if (!*sf) return OutOfMemory;
54 (*sf)->brush.lb.lbStyle = BS_SOLID;
55 (*sf)->brush.lb.lbColor = col;
56 (*sf)->brush.lb.lbHatch = 0;
58 (*sf)->brush.gdibrush = CreateSolidBrush(col);
59 (*sf)->brush.bt = BrushTypeSolidColor;
60 (*sf)->color = color;
62 return Ok;
65 GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
67 if(!brush || !type) return InvalidParameter;
69 *type = brush->bt;
71 return Ok;
74 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
76 if(!brush) return InvalidParameter;
78 DeleteObject(brush->gdibrush);
79 GdipFree(brush);
81 return Ok;
84 GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
86 if(!sf || !argb)
87 return InvalidParameter;
89 *argb = sf->color;
91 return Ok;
94 GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
96 if(!sf)
97 return InvalidParameter;
99 sf->color = argb;
100 sf->brush.lb.lbColor = ARGB2COLORREF(argb);
102 DeleteObject(sf->brush.gdibrush);
103 sf->brush.gdibrush = CreateSolidBrush(sf->brush.lb.lbColor);
105 return Ok;