Small fix for the patch special char patch earlier.
[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 CreateSolidBrush(IN COLORREF crColor)
86 {
87 /* Call Server-Side API */
88 return NtGdiCreateSolidBrush(crColor, NULL);
89 }
90
91 /*
92 * @implemented
93 */
94 HBRUSH STDCALL
95 CreateBrushIndirect(
96 CONST LOGBRUSH *LogBrush)
97 {
98 HBRUSH hBrush;
99
100 switch (LogBrush->lbStyle)
101 {
102 case BS_DIBPATTERN8X8:
103 case BS_DIBPATTERN:
104 hBrush = CreateDIBPatternBrush((HGLOBAL)LogBrush->lbHatch,
105 LogBrush->lbColor);
106 break;
107
108 case BS_DIBPATTERNPT:
109 hBrush = CreateDIBPatternBrushPt((PVOID)LogBrush->lbHatch,
110 LogBrush->lbColor);
111 break;
112
113 case BS_PATTERN:
114 case BS_PATTERN8X8:
115 hBrush = NtGdiCreatePatternBrush((HBITMAP)LogBrush->lbHatch);
116 break;
117
118 case BS_SOLID:
119 hBrush = NtGdiCreateSolidBrush(LogBrush->lbColor, 0);
120 break;
121
122 case BS_HATCHED:
123 hBrush = NtGdiCreateHatchBrush(LogBrush->lbHatch, LogBrush->lbColor);
124 break;
125
126 case BS_NULL:
127 hBrush = NtGdiGetStockObject(NULL_BRUSH);
128 break;
129
130 default:
131 SetLastError(ERROR_INVALID_PARAMETER);
132 hBrush = NULL;
133 break;
134 }
135
136 return hBrush;
137 }
138