Added little prog. that builds the WIN32K.SYS service table
[reactos.git] / reactos / subsys / win32k / objects / brush.c
1 /* $Id: brush.c,v 1.8 2000/02/20 22:52:50 ea Exp $
2 */
3
4
5 #undef WIN32_LEAN_AND_MEAN
6 #include <windows.h>
7 #include <ddk/ntddk.h>
8 #include <win32k/bitmaps.h>
9 #include <win32k/brush.h>
10 //#include <win32k/debug.h>
11
12 // #define NDEBUG
13 #include <internal/debug.h>
14
15 HBRUSH STDCALL W32kCreateBrushIndirect(CONST LOGBRUSH *lb)
16 {
17 PBRUSHOBJ brushPtr;
18 HBRUSH hBrush;
19
20 hBrush = BRUSHOBJ_AllocBrush ();
21 if (hBrush == NULL)
22 {
23 return 0;
24 }
25
26 brushPtr = BRUSHOBJ_HandleToPtr (hBrush);
27 brushPtr->logbrush.lbStyle = lb->lbStyle;
28 brushPtr->logbrush.lbColor = lb->lbColor;
29 brushPtr->logbrush.lbHatch = lb->lbHatch;
30 BRUSHOBJ_UnlockBrush (hBrush);
31 DPRINT("%08x\n", hBrush);
32
33 return hBrush;
34 }
35
36 HBRUSH STDCALL W32kCreateDIBPatternBrush(HGLOBAL hDIBPacked,
37 UINT ColorSpec)
38 {
39 UNIMPLEMENTED;
40 #if 0
41 LOGBRUSH logbrush;
42 PBITMAPINFO info, newInfo;
43 INT size;
44
45 DPRINT("%04x\n", hbitmap );
46
47 logbrush.lbStyle = BS_DIBPATTERN;
48 logbrush.lbColor = coloruse;
49 logbrush.lbHatch = 0;
50
51 /* Make a copy of the bitmap */
52 if (!(info = (BITMAPINFO *)GlobalLock( hbitmap )))
53 {
54 return 0;
55 }
56
57
58 if (info->bmiHeader.biCompression)
59 size = info->bmiHeader.biSizeImage;
60 else
61 size = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
62 info->bmiHeader.biHeight,
63 info->bmiHeader.biBitCount);
64 size += DIB_BitmapInfoSize( info, coloruse );
65
66 if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
67 {
68 GlobalUnlock16( hbitmap );
69 return 0;
70 }
71 newInfo = (BITMAPINFO *) GlobalLock16( (HGLOBAL16)logbrush.lbHatch );
72 memcpy( newInfo, info, size );
73 GlobalUnlock16( (HGLOBAL16)logbrush.lbHatch );
74 GlobalUnlock( hbitmap );
75 return W32kCreateBrushIndirect( &logbrush );
76 #endif
77 }
78
79 HBRUSH STDCALL W32kCreateDIBPatternBrushPt(CONST VOID *PackedDIB,
80 UINT Usage)
81 {
82 INT size;
83 LOGBRUSH logbrush;
84 PBITMAPINFO info;
85 PBITMAPINFO newInfo;
86
87 info = (BITMAPINFO *) PackedDIB;
88 if (info == NULL)
89 {
90 return 0;
91 }
92 DPRINT ("%p %ldx%ld %dbpp\n",
93 info,
94 info->bmiHeader.biWidth,
95 info->bmiHeader.biHeight,
96 info->bmiHeader.biBitCount);
97
98 logbrush.lbStyle = BS_DIBPATTERN;
99 logbrush.lbColor = Usage;
100 logbrush.lbHatch = 0;
101
102 /* Make a copy of the bitmap */
103
104 if (info->bmiHeader.biCompression)
105 {
106 size = info->bmiHeader.biSizeImage;
107 }
108 else
109 {
110 size = DIB_GetDIBImageBytes (info->bmiHeader.biWidth,
111 info->bmiHeader.biHeight,
112 info->bmiHeader.biBitCount);
113 }
114 size += DIB_BitmapInfoSize (info, Usage);
115
116 logbrush.lbHatch = (INT)
117 GDIOBJ_PtrToHandle (GDIOBJ_AllocObject (size, GO_MAGIC_DONTCARE),
118 GO_MAGIC_DONTCARE);
119 if (logbrush.lbHatch == 0)
120 {
121 return 0;
122 }
123 newInfo = (PBITMAPINFO) GDIOBJ_HandleToPtr ((HGDIOBJ) logbrush.lbHatch,
124 GO_MAGIC_DONTCARE);
125 memcpy (newInfo, info, size);
126 GDIOBJ_UnlockObject ((HGDIOBJ) logbrush.lbHatch);
127
128 return W32kCreateBrushIndirect (&logbrush);
129 }
130
131 HBRUSH STDCALL W32kCreateHatchBrush(INT Style,
132 COLORREF Color)
133 {
134 LOGBRUSH logbrush;
135
136 DPRINT("%d %06lx\n", Style, Color);
137
138 if (Style < 0 || Style >= NB_HATCH_STYLES)
139 {
140 return 0;
141 }
142 logbrush.lbStyle = BS_HATCHED;
143 logbrush.lbColor = Color;
144 logbrush.lbHatch = Style;
145
146 return W32kCreateBrushIndirect (&logbrush);
147 }
148
149 HBRUSH STDCALL W32kCreatePatternBrush(HBITMAP hBitmap)
150 {
151 LOGBRUSH logbrush = { BS_PATTERN, 0, 0 };
152
153 DPRINT ("%04x\n", hBitmap);
154 logbrush.lbHatch = (INT) BITMAPOBJ_CopyBitmap (hBitmap);
155 if(!logbrush.lbHatch)
156 {
157 return 0;
158 }
159 else
160 {
161 return W32kCreateBrushIndirect( &logbrush );
162 }
163 }
164
165 HBRUSH STDCALL W32kCreateSolidBrush(COLORREF Color)
166 {
167 UNIMPLEMENTED;
168 }
169
170 BOOL STDCALL W32kFixBrushOrgEx(VOID)
171 {
172 return FALSE;
173 }
174
175 BOOL STDCALL W32kPatBlt(HDC hDC,
176 INT XLeft,
177 INT YLeft,
178 INT Width,
179 INT Height,
180 DWORD ROP)
181 {
182 UNIMPLEMENTED;
183 }
184
185 BOOL STDCALL W32kSetBrushOrgEx(HDC hDC,
186 INT XOrg,
187 INT YOrg,
188 LPPOINT Point)
189 {
190 UNIMPLEMENTED;
191 }
192
193