2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #undef WIN32_LEAN_AND_MEAN
25 #include <ddk/ntddk.h>
26 #include <win32k/bitmaps.h>
27 #include <win32k/brush.h>
28 //#include <win32k/debug.h>
29 #include <include/object.h>
30 #include <include/inteng.h>
31 #include <include/error.h>
34 #include <win32k/debug1.h>
36 HBRUSH STDCALL NtGdiCreateBrushIndirect(CONST LOGBRUSH *lb)
41 hBrush = BRUSHOBJ_AllocBrush();
47 brushPtr = BRUSHOBJ_LockBrush (hBrush);
48 /* FIXME: Occurs! FiN */
49 /* ASSERT( brushPtr ); *///I want to know if this ever occurs
52 brushPtr->iSolidColor = lb->lbColor;
53 brushPtr->logbrush.lbStyle = lb->lbStyle;
54 brushPtr->logbrush.lbColor = lb->lbColor;
55 brushPtr->logbrush.lbHatch = lb->lbHatch;
57 BRUSHOBJ_UnlockBrush( hBrush );
63 HBRUSH STDCALL NtGdiCreateDIBPatternBrush(HGLOBAL hDIBPacked,
69 PBITMAPINFO info, newInfo;
72 DPRINT("%04x\n", hbitmap );
74 logbrush.lbStyle = BS_DIBPATTERN;
75 logbrush.lbColor = coloruse;
78 /* Make a copy of the bitmap */
79 if (!(info = (BITMAPINFO *)GlobalLock( hbitmap )))
85 if (info->bmiHeader.biCompression) size = info->bmiHeader.biSizeImage;
87 size = DIB_GetDIBImageBytes(info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biBitCount);
88 size += DIB_BitmapInfoSize(info, coloruse);
90 if (!(logbrush.lbHatch = (INT)GlobalAlloc16( GMEM_MOVEABLE, size )))
92 GlobalUnlock16( hbitmap );
95 newInfo = (BITMAPINFO *) GlobalLock16((HGLOBAL16)logbrush.lbHatch);
96 memcpy(newInfo, info, size);
97 GlobalUnlock16((HGLOBAL16)logbrush.lbHatch);
98 GlobalUnlock(hbitmap);
99 return NtGdiCreateBrushIndirect(&logbrush);
103 HBRUSH STDCALL NtGdiCreateDIBPatternBrushPt(CONST VOID *PackedDIB,
111 info = (BITMAPINFO *) PackedDIB;
116 DPRINT ("%p %ldx%ld %dbpp\n",
118 info->bmiHeader.biWidth,
119 info->bmiHeader.biHeight,
120 info->bmiHeader.biBitCount);
122 logbrush.lbStyle = BS_DIBPATTERN;
123 logbrush.lbColor = Usage;
124 logbrush.lbHatch = 0;
126 /* Make a copy of the bitmap */
128 if (info->bmiHeader.biCompression)
130 size = info->bmiHeader.biSizeImage;
134 size = DIB_GetDIBImageBytes (info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biBitCount);
136 size += DIB_BitmapInfoSize (info, Usage);
138 logbrush.lbHatch = (LONG) GDIOBJ_AllocObj(size, GDI_OBJECT_TYPE_DONTCARE, NULL);
139 if (logbrush.lbHatch == 0)
143 newInfo = (PBITMAPINFO) GDIOBJ_LockObj ((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE);
145 memcpy(newInfo, info, size);
146 GDIOBJ_UnlockObj((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE);
148 return NtGdiCreateBrushIndirect (&logbrush);
151 HBRUSH STDCALL NtGdiCreateHatchBrush(INT Style,
156 DPRINT("%d %06lx\n", Style, Color);
158 if (Style < 0 || Style >= NB_HATCH_STYLES)
162 logbrush.lbStyle = BS_HATCHED;
163 logbrush.lbColor = Color;
164 logbrush.lbHatch = Style;
166 return NtGdiCreateBrushIndirect (&logbrush);
169 HBRUSH STDCALL NtGdiCreatePatternBrush(HBITMAP hBitmap)
171 LOGBRUSH logbrush = { BS_PATTERN, 0, 0 };
173 DPRINT ("%04x\n", hBitmap);
174 logbrush.lbHatch = (INT) BITMAPOBJ_CopyBitmap (hBitmap);
175 if(!logbrush.lbHatch)
181 return NtGdiCreateBrushIndirect( &logbrush );
185 HBRUSH STDCALL NtGdiCreateSolidBrush(COLORREF Color)
189 logbrush.lbStyle = BS_SOLID;
190 logbrush.lbColor = Color;
191 logbrush.lbHatch = 0;
193 return NtGdiCreateBrushIndirect(&logbrush);
196 BOOL STDCALL NtGdiFixBrushOrgEx(VOID)
201 BOOL STDCALL IntPatBlt(DC *dc,
213 SurfObj = (SURFOBJ*)AccessUserObject((ULONG)dc->Surface);
216 if (BrushObj->logbrush.lbStyle != BS_NULL)
220 DestRect.left = XLeft + dc->w.DCOrgX;
221 DestRect.right = XLeft + Width + dc->w.DCOrgX;
225 DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX;
226 DestRect.right = XLeft + dc->w.DCOrgX + 1;
230 DestRect.top = YLeft + dc->w.DCOrgY;
231 DestRect.bottom = YLeft + Height + dc->w.DCOrgY;
235 DestRect.top = YLeft + Height + dc->w.DCOrgY + 1;
236 DestRect.bottom = YLeft + dc->w.DCOrgY + 1;
238 ret = IntEngBitBlt(SurfObj,
253 BOOL STDCALL NtGdiPolyPatBlt(HDC hDC,
262 DC *dc = DC_LockDc(hDC);
265 SetLastWin32Error(ERROR_INVALID_HANDLE);
268 for (i = 0;i<cRects;i++)
271 BrushObj = BRUSHOBJ_LockBrush(r.hBrush);
272 IntPatBlt(dc,r.r.left,r.r.top,r.r.right,r.r.bottom,dwRop,BrushObj);
273 BRUSHOBJ_UnlockBrush(r.hBrush);
280 BOOL STDCALL NtGdiPatBlt(HDC hDC,
288 DC *dc = DC_LockDc(hDC);
293 SetLastWin32Error(ERROR_INVALID_HANDLE);
297 BrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
298 ret = IntPatBlt(dc,XLeft,YLeft,Width,Height,ROP,BrushObj);
300 BRUSHOBJ_UnlockBrush(dc->w.hBrush);
305 BOOL STDCALL NtGdiSetBrushOrgEx(HDC hDC,