* Replace NtGdiCreatePatternBrush and NtGdiCreateHatchBrush with NtGdiCreatePatternBr...
[reactos.git] / reactos / lib / gdi32 / objects / brush.c
1 #include "precomp.h"
2
3 #define NDEBUG
4 #include <debug.h>
5
6 /*
7 * @implemented
8 */
9 BOOL
10 STDCALL
11 FixBrushOrgEx(
12 HDC hDC,
13 INT nXOrg,
14 INT nYOrg,
15 LPPOINT lpPoint)
16 {
17 return FALSE;
18 }
19
20 /*
21 * @implemented
22 */
23 HBRUSH STDCALL
24 CreateDIBPatternBrush(
25 HGLOBAL hglbDIBPacked,
26 UINT fuColorSpec)
27 {
28 PVOID lpPackedDIB;
29 HBRUSH hBrush = NULL;
30 PBITMAPINFO pConvertedInfo;
31 UINT ConvertedInfoSize;
32
33 lpPackedDIB = GlobalLock(hglbDIBPacked);
34 if (lpPackedDIB == NULL)
35 return 0;
36
37 pConvertedInfo = ConvertBitmapInfo((PBITMAPINFO)lpPackedDIB, fuColorSpec,
38 &ConvertedInfoSize, TRUE);
39 if (pConvertedInfo)
40 {
41 hBrush = NtGdiCreateDIBBrush(pConvertedInfo, fuColorSpec,
42 ConvertedInfoSize, FALSE, FALSE, lpPackedDIB);
43 if ((PBITMAPINFO)lpPackedDIB != pConvertedInfo)
44 RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);
45 }
46
47 GlobalUnlock(hglbDIBPacked);
48
49 return hBrush;
50 }
51
52 /*
53 * @implemented
54 */
55 HBRUSH STDCALL
56 CreateDIBPatternBrushPt(
57 CONST VOID *lpPackedDIB,
58 UINT fuColorSpec)
59 {
60 HBRUSH hBrush = NULL;
61 PBITMAPINFO pConvertedInfo;
62 UINT ConvertedInfoSize;
63
64 if (lpPackedDIB == NULL)
65 return 0;
66
67 pConvertedInfo = ConvertBitmapInfo((PBITMAPINFO)lpPackedDIB, fuColorSpec,
68 &ConvertedInfoSize, TRUE);
69 if (pConvertedInfo)
70 {
71 hBrush = NtGdiCreateDIBBrush(pConvertedInfo, fuColorSpec,
72 ConvertedInfoSize, FALSE, FALSE, (PVOID)lpPackedDIB);
73 if ((PBITMAPINFO)lpPackedDIB != pConvertedInfo)
74 RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo);
75 }
76
77 return hBrush;
78 }
79
80 /*
81 * @implemented
82 */
83 HBRUSH
84 STDCALL
85 CreateHatchBrush(INT fnStyle,
86 COLORREF clrref)
87 {
88 return NtGdiCreateHatchBrushInternal(fnStyle, clrref, FALSE);
89 }
90
91 /*
92 * @implemented
93 */
94 HBRUSH
95 STDCALL
96 CreatePatternBrush(HBITMAP hbmp)
97 {
98 return NtGdiCreatePatternBrushInternal(hbmp, FALSE, FALSE);
99 }
100
101 /*
102 * @implemented
103 */
104 HBRUSH
105 STDCALL
106 CreateSolidBrush(IN COLORREF crColor)
107 {
108 /* Call Server-Side API */
109 return NtGdiCreateSolidBrush(crColor, NULL);
110 }
111
112 /*
113 * @implemented
114 */
115 HBRUSH STDCALL
116 CreateBrushIndirect(
117 CONST LOGBRUSH *LogBrush)
118 {
119 HBRUSH hBrush;
120
121 switch (LogBrush->lbStyle)
122 {
123 case BS_DIBPATTERN8X8:
124 case BS_DIBPATTERN:
125 hBrush = CreateDIBPatternBrush((HGLOBAL)LogBrush->lbHatch,
126 LogBrush->lbColor);
127 break;
128
129 case BS_DIBPATTERNPT:
130 hBrush = CreateDIBPatternBrushPt((PVOID)LogBrush->lbHatch,
131 LogBrush->lbColor);
132 break;
133
134 case BS_PATTERN:
135 hBrush = NtGdiCreatePatternBrushInternal((HBITMAP)LogBrush->lbHatch,
136 FALSE,
137 FALSE);
138 break;
139
140 case BS_PATTERN8X8:
141 hBrush = NtGdiCreatePatternBrushInternal((HBITMAP)LogBrush->lbHatch,
142 FALSE,
143 TRUE);
144 break;
145
146 case BS_SOLID:
147 hBrush = NtGdiCreateSolidBrush(LogBrush->lbColor, 0);
148 break;
149
150 case BS_HATCHED:
151 hBrush = NtGdiCreateHatchBrushInternal(LogBrush->lbHatch,
152 LogBrush->lbColor,
153 FALSE);
154 break;
155
156 case BS_NULL:
157 hBrush = NtGdiGetStockObject(NULL_BRUSH);
158 break;
159
160 default:
161 SetLastError(ERROR_INVALID_PARAMETER);
162 hBrush = NULL;
163 break;
164 }
165
166 return hBrush;
167 }
168