4 * Copyright 1993, 1994 Alexandre Julliard
13 DEFAULT_DEBUG_CHANNEL(gdi
)
16 /***********************************************************************
17 * CreateBrushIndirect16 (GDI.50)
19 HBRUSH16 WINAPI
CreateBrushIndirect16( const LOGBRUSH16
* brush
)
22 HBRUSH16 hbrush
= GDI_AllocObject( sizeof(BRUSHOBJ
), BRUSH_MAGIC
);
23 if (!hbrush
) return 0;
24 brushPtr
= (BRUSHOBJ
*) GDI_HEAP_LOCK( hbrush
);
25 brushPtr
->logbrush
.lbStyle
= brush
->lbStyle
;
26 brushPtr
->logbrush
.lbColor
= brush
->lbColor
;
27 brushPtr
->logbrush
.lbHatch
= brush
->lbHatch
;
28 GDI_HEAP_UNLOCK( hbrush
);
29 TRACE(gdi
, "%04x\n", hbrush
);
34 /***********************************************************************
35 * CreateBrushIndirect32 (GDI32.27)
37 HBRUSH WINAPI
CreateBrushIndirect( const LOGBRUSH
* brush
)
40 HBRUSH hbrush
= GDI_AllocObject( sizeof(BRUSHOBJ
), BRUSH_MAGIC
);
41 if (!hbrush
) return 0;
42 brushPtr
= (BRUSHOBJ
*) GDI_HEAP_LOCK( hbrush
);
43 brushPtr
->logbrush
.lbStyle
= brush
->lbStyle
;
44 brushPtr
->logbrush
.lbColor
= brush
->lbColor
;
45 brushPtr
->logbrush
.lbHatch
= brush
->lbHatch
;
46 GDI_HEAP_UNLOCK( hbrush
);
47 TRACE(gdi
, "%08x\n", hbrush
);
52 /***********************************************************************
53 * CreateHatchBrush16 (GDI.58)
55 HBRUSH16 WINAPI
CreateHatchBrush16( INT16 style
, COLORREF color
)
59 TRACE(gdi
, "%d %06lx\n", style
, color
);
61 logbrush
.lbStyle
= BS_HATCHED
;
62 logbrush
.lbColor
= color
;
63 logbrush
.lbHatch
= style
;
65 if ((style
< 0) || (style
>= NB_HATCH_STYLES
)) return 0;
66 return CreateBrushIndirect( &logbrush
);
70 /***********************************************************************
71 * CreateHatchBrush32 (GDI32.48)
73 HBRUSH WINAPI
CreateHatchBrush( INT style
, COLORREF color
)
77 TRACE(gdi
, "%d %06lx\n", style
, color
);
79 logbrush
.lbStyle
= BS_HATCHED
;
80 logbrush
.lbColor
= color
;
81 logbrush
.lbHatch
= style
;
83 if ((style
< 0) || (style
>= NB_HATCH_STYLES
)) return 0;
84 return CreateBrushIndirect( &logbrush
);
88 /***********************************************************************
89 * CreatePatternBrush16 (GDI.60)
91 HBRUSH16 WINAPI
CreatePatternBrush16( HBITMAP16 hbitmap
)
93 return (HBRUSH16
)CreatePatternBrush( hbitmap
);
97 /***********************************************************************
98 * CreatePatternBrush32 (GDI32.54)
100 HBRUSH WINAPI
CreatePatternBrush( HBITMAP hbitmap
)
102 LOGBRUSH logbrush
= { BS_PATTERN
, 0, 0 };
103 TRACE(gdi
, "%04x\n", hbitmap
);
105 logbrush
.lbHatch
= (INT
)BITMAP_CopyBitmap( hbitmap
);
106 if(!logbrush
.lbHatch
)
109 return CreateBrushIndirect( &logbrush
);
113 /***********************************************************************
114 * CreateDIBPatternBrush16 (GDI.445)
116 HBRUSH16 WINAPI
CreateDIBPatternBrush16( HGLOBAL16 hbitmap
, UINT16 coloruse
)
119 BITMAPINFO
*info
, *newInfo
;
122 TRACE(gdi
, "%04x\n", hbitmap
);
124 logbrush
.lbStyle
= BS_DIBPATTERN
;
125 logbrush
.lbColor
= coloruse
;
126 logbrush
.lbHatch
= 0;
128 /* Make a copy of the bitmap */
130 if (!(info
= (BITMAPINFO
*)GlobalLock16( hbitmap
))) return 0;
132 if (info
->bmiHeader
.biCompression
)
133 size
= info
->bmiHeader
.biSizeImage
;
135 size
= DIB_GetDIBImageBytes(info
->bmiHeader
.biWidth
,
136 info
->bmiHeader
.biHeight
,
137 info
->bmiHeader
.biBitCount
);
138 size
+= DIB_BitmapInfoSize( info
, coloruse
);
140 if (!(logbrush
.lbHatch
= (INT16
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
142 GlobalUnlock16( hbitmap
);
145 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
146 memcpy( newInfo
, info
, size
);
147 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
148 GlobalUnlock16( hbitmap
);
149 return CreateBrushIndirect( &logbrush
);
153 /***********************************************************************
154 * CreateDIBPatternBrush32 (GDI32.34)
156 * Create a logical brush which has the pattern specified by the DIB
158 * Function call is for compatability only. CreateDIBPatternBrushPt should be used.
162 * Handle to a logical brush on success, NULL on failure.
167 HBRUSH WINAPI
CreateDIBPatternBrush(
168 HGLOBAL hbitmap
, /* Global object containg BITMAPINFO structure */
169 UINT coloruse
/* Specifies color format, if provided */
173 BITMAPINFO
*info
, *newInfo
;
176 TRACE(gdi
, "%04x\n", hbitmap
);
178 logbrush
.lbStyle
= BS_DIBPATTERN
;
179 logbrush
.lbColor
= coloruse
;
180 logbrush
.lbHatch
= 0;
182 /* Make a copy of the bitmap */
184 if (!(info
= (BITMAPINFO
*)GlobalLock( hbitmap
))) return 0;
186 if (info
->bmiHeader
.biCompression
)
187 size
= info
->bmiHeader
.biSizeImage
;
189 size
= DIB_GetDIBImageBytes(info
->bmiHeader
.biWidth
,
190 info
->bmiHeader
.biHeight
,
191 info
->bmiHeader
.biBitCount
);
192 size
+= DIB_BitmapInfoSize( info
, coloruse
);
194 if (!(logbrush
.lbHatch
= (INT
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
196 GlobalUnlock16( hbitmap
);
199 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
200 memcpy( newInfo
, info
, size
);
201 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
202 GlobalUnlock( hbitmap
);
203 return CreateBrushIndirect( &logbrush
);
207 /***********************************************************************
208 * CreateDIBPatternBrushPt (GDI32.35)
210 * Create a logical brush which has the pattern specified by the DIB
214 * Handle to a logical brush on success, NULL on failure.
219 HBRUSH WINAPI
CreateDIBPatternBrushPt(
220 const void* data
, /* Pointer to a BITMAPINFO structure followed by more data */
221 UINT coloruse
/* Specifies color format, if provided */
224 BITMAPINFO
*info
=(BITMAPINFO
*)data
;
225 LOGBRUSH logbrush
= { BS_DIBPATTERN
, coloruse
, 0 };
229 TRACE(gdi
, "%p %ldx%ld %dbpp\n", info
, info
->bmiHeader
.biWidth
,
230 info
->bmiHeader
.biHeight
, info
->bmiHeader
.biBitCount
);
232 /* Make a copy of the bitmap */
235 if (info
->bmiHeader
.biCompression
)
236 size
= info
->bmiHeader
.biSizeImage
;
238 size
= DIB_GetDIBImageBytes(info
->bmiHeader
.biWidth
,
239 info
->bmiHeader
.biHeight
,
240 info
->bmiHeader
.biBitCount
);
241 size
+= DIB_BitmapInfoSize( info
, coloruse
);
243 if (!(logbrush
.lbHatch
= (INT
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
247 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
248 memcpy( newInfo
, info
, size
);
249 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
250 return CreateBrushIndirect( &logbrush
);
254 /***********************************************************************
255 * CreateSolidBrush (GDI.66)
257 HBRUSH16 WINAPI
CreateSolidBrush16( COLORREF color
)
261 TRACE(gdi
, "%06lx\n", color
);
263 logbrush
.lbStyle
= BS_SOLID
;
264 logbrush
.lbColor
= color
;
265 logbrush
.lbHatch
= 0;
267 return CreateBrushIndirect( &logbrush
);
271 /***********************************************************************
272 * CreateSolidBrush32 (GDI32.64)
274 HBRUSH WINAPI
CreateSolidBrush( COLORREF color
)
278 TRACE(gdi
, "%06lx\n", color
);
280 logbrush
.lbStyle
= BS_SOLID
;
281 logbrush
.lbColor
= color
;
282 logbrush
.lbHatch
= 0;
284 return CreateBrushIndirect( &logbrush
);
288 /***********************************************************************
289 * SetBrushOrg (GDI.148)
291 DWORD WINAPI
SetBrushOrg16( HDC16 hdc
, INT16 x
, INT16 y
)
294 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
295 if (!dc
) return FALSE
;
296 retval
= dc
->w
.brushOrgX
| (dc
->w
.brushOrgY
<< 16);
303 /***********************************************************************
304 * SetBrushOrgEx (GDI32.308)
306 BOOL WINAPI
SetBrushOrgEx( HDC hdc
, INT x
, INT y
, LPPOINT oldorg
)
308 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
310 if (!dc
) return FALSE
;
313 oldorg
->x
= dc
->w
.brushOrgX
;
314 oldorg
->y
= dc
->w
.brushOrgY
;
321 /***********************************************************************
322 * FixBrushOrgEx (GDI32.102)
323 * SDK says discontinued, but in Win95 GDI32 this is the same as SetBrushOrgEx
325 BOOL WINAPI
FixBrushOrgEx( HDC hdc
, INT x
, INT y
, LPPOINT oldorg
)
327 return SetBrushOrgEx(hdc
,x
,y
,oldorg
);
331 /***********************************************************************
334 BOOL
BRUSH_DeleteObject( HBRUSH16 hbrush
, BRUSHOBJ
* brush
)
336 switch(brush
->logbrush
.lbStyle
)
339 DeleteObject( (HGDIOBJ
)brush
->logbrush
.lbHatch
);
342 GlobalFree16( (HGLOBAL16
)brush
->logbrush
.lbHatch
);
345 return GDI_FreeObject( hbrush
);
349 /***********************************************************************
352 INT16
BRUSH_GetObject16( BRUSHOBJ
* brush
, INT16 count
, LPSTR buffer
)
356 logbrush
.lbStyle
= brush
->logbrush
.lbStyle
;
357 logbrush
.lbColor
= brush
->logbrush
.lbColor
;
358 logbrush
.lbHatch
= brush
->logbrush
.lbHatch
;
359 if (count
> sizeof(logbrush
)) count
= sizeof(logbrush
);
360 memcpy( buffer
, &logbrush
, count
);
365 /***********************************************************************
368 INT
BRUSH_GetObject( BRUSHOBJ
* brush
, INT count
, LPSTR buffer
)
370 if (count
> sizeof(brush
->logbrush
)) count
= sizeof(brush
->logbrush
);
371 memcpy( buffer
, &brush
->logbrush
, count
);
376 /***********************************************************************
377 * SetSolidBrush16 (GDI.604)
379 * If hBrush is a solid brush, change it's color to newColor.
382 * TRUE on success, FALSE on failure.
383 * FIXME: not yet implemented!
385 BOOL16 WINAPI
SetSolidBrush16(HBRUSH16 hBrush
, COLORREF newColor
)
387 FIXME(gdi
, "(hBrush %04x, newColor %04x): stub!\n", hBrush
, (int)newColor
);