4 * Copyright 1993, 1994 Alexandre Julliard
13 /***********************************************************************
14 * CreateBrushIndirect16 (GDI.50)
16 HBRUSH16 WINAPI
CreateBrushIndirect16( const LOGBRUSH16
* brush
)
19 HBRUSH16 hbrush
= GDI_AllocObject( sizeof(BRUSHOBJ
), BRUSH_MAGIC
);
20 if (!hbrush
) return 0;
21 brushPtr
= (BRUSHOBJ
*) GDI_HEAP_LOCK( hbrush
);
22 brushPtr
->logbrush
.lbStyle
= brush
->lbStyle
;
23 brushPtr
->logbrush
.lbColor
= brush
->lbColor
;
24 brushPtr
->logbrush
.lbHatch
= brush
->lbHatch
;
25 GDI_HEAP_UNLOCK( hbrush
);
26 TRACE(gdi
, "%04x\n", hbrush
);
31 /***********************************************************************
32 * CreateBrushIndirect32 (GDI32.27)
34 HBRUSH32 WINAPI
CreateBrushIndirect32( const LOGBRUSH32
* brush
)
37 HBRUSH32 hbrush
= GDI_AllocObject( sizeof(BRUSHOBJ
), BRUSH_MAGIC
);
38 if (!hbrush
) return 0;
39 brushPtr
= (BRUSHOBJ
*) GDI_HEAP_LOCK( hbrush
);
40 brushPtr
->logbrush
.lbStyle
= brush
->lbStyle
;
41 brushPtr
->logbrush
.lbColor
= brush
->lbColor
;
42 brushPtr
->logbrush
.lbHatch
= brush
->lbHatch
;
43 GDI_HEAP_UNLOCK( hbrush
);
44 TRACE(gdi
, "%08x\n", hbrush
);
49 /***********************************************************************
50 * CreateHatchBrush16 (GDI.58)
52 HBRUSH16 WINAPI
CreateHatchBrush16( INT16 style
, COLORREF color
)
54 LOGBRUSH32 logbrush
= { BS_HATCHED
, color
, style
};
55 TRACE(gdi
, "%d %06lx\n", style
, color
);
56 if ((style
< 0) || (style
>= NB_HATCH_STYLES
)) return 0;
57 return CreateBrushIndirect32( &logbrush
);
61 /***********************************************************************
62 * CreateHatchBrush32 (GDI32.48)
64 HBRUSH32 WINAPI
CreateHatchBrush32( INT32 style
, COLORREF color
)
66 LOGBRUSH32 logbrush
= { BS_HATCHED
, color
, style
};
67 TRACE(gdi
, "%d %06lx\n", style
, color
);
68 if ((style
< 0) || (style
>= NB_HATCH_STYLES
)) return 0;
69 return CreateBrushIndirect32( &logbrush
);
73 /***********************************************************************
74 * CreatePatternBrush16 (GDI.60)
76 HBRUSH16 WINAPI
CreatePatternBrush16( HBITMAP16 hbitmap
)
78 return (HBRUSH16
)CreatePatternBrush32( hbitmap
);
82 /***********************************************************************
83 * CreatePatternBrush32 (GDI32.54)
85 HBRUSH32 WINAPI
CreatePatternBrush32( HBITMAP32 hbitmap
)
87 LOGBRUSH32 logbrush
= { BS_PATTERN
, 0, 0 };
88 TRACE(gdi
, "%04x\n", hbitmap
);
90 logbrush
.lbHatch
= (INT32
)BITMAP_CopyBitmap( hbitmap
);
94 return CreateBrushIndirect32( &logbrush
);
98 /***********************************************************************
99 * CreateDIBPatternBrush16 (GDI.445)
101 HBRUSH16 WINAPI
CreateDIBPatternBrush16( HGLOBAL16 hbitmap
, UINT16 coloruse
)
103 LOGBRUSH32 logbrush
= { BS_DIBPATTERN
, coloruse
, 0 };
104 BITMAPINFO
*info
, *newInfo
;
107 TRACE(gdi
, "%04x\n", hbitmap
);
109 /* Make a copy of the bitmap */
111 if (!(info
= (BITMAPINFO
*)GlobalLock16( hbitmap
))) return 0;
113 if (info
->bmiHeader
.biCompression
)
114 size
= info
->bmiHeader
.biSizeImage
;
116 size
= DIB_GetDIBWidthBytes(info
->bmiHeader
.biWidth
,
117 info
->bmiHeader
.biBitCount
) *
118 info
->bmiHeader
.biHeight
;
119 size
+= DIB_BitmapInfoSize( info
, coloruse
);
121 if (!(logbrush
.lbHatch
= (INT16
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
123 GlobalUnlock16( hbitmap
);
126 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
127 memcpy( newInfo
, info
, size
);
128 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
129 GlobalUnlock16( hbitmap
);
130 return CreateBrushIndirect32( &logbrush
);
134 /***********************************************************************
135 * CreateDIBPatternBrush32 (GDI32.34)
137 * Create a logical brush which has the pattern specified by the DIB
139 * Function call is for compatability only. CreateDIBPatternBrushPt should be used.
143 * Handle to a logical brush on success, NULL on failure.
148 HBRUSH32 WINAPI
CreateDIBPatternBrush32(
149 HGLOBAL32 hbitmap
, /* Global object containg BITMAPINFO structure */
150 UINT32 coloruse
/* Specifies color format, if provided */
153 LOGBRUSH32 logbrush
= { BS_DIBPATTERN
, coloruse
, 0 };
154 BITMAPINFO
*info
, *newInfo
;
157 TRACE(gdi
, "%04x\n", hbitmap
);
159 /* Make a copy of the bitmap */
161 if (!(info
= (BITMAPINFO
*)GlobalLock32( hbitmap
))) return 0;
163 if (info
->bmiHeader
.biCompression
)
164 size
= info
->bmiHeader
.biSizeImage
;
166 size
= DIB_GetDIBWidthBytes(info
->bmiHeader
.biWidth
,
167 info
->bmiHeader
.biBitCount
) *
168 info
->bmiHeader
.biHeight
;
169 size
+= DIB_BitmapInfoSize( info
, coloruse
);
171 if (!(logbrush
.lbHatch
= (INT32
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
173 GlobalUnlock16( hbitmap
);
176 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
177 memcpy( newInfo
, info
, size
);
178 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
179 GlobalUnlock32( hbitmap
);
180 return CreateBrushIndirect32( &logbrush
);
184 /***********************************************************************
185 * CreateDIBPatternBrushPt (GDI32.35)
187 * Create a logical brush which has the pattern specified by the DIB
191 * Handle to a logical brush on success, NULL on failure.
196 HBRUSH32 WINAPI
CreateDIBPatternBrushPt(
197 const void* data
, /* Pointer to a BITMAPINFO structure followed by more data */
198 UINT32 coloruse
/* Specifies color format, if provided */
201 BITMAPINFO
*info
=(BITMAPINFO
*)data
;
202 LOGBRUSH32 logbrush
= { BS_DIBPATTERN
, coloruse
, 0 };
206 TRACE(gdi
, "%p\n", info
);
208 /* Make a copy of the bitmap */
211 if (info
->bmiHeader
.biCompression
)
212 size
= info
->bmiHeader
.biSizeImage
;
214 size
= DIB_GetDIBWidthBytes(info
->bmiHeader
.biWidth
,
215 info
->bmiHeader
.biBitCount
) *
216 info
->bmiHeader
.biHeight
;
217 size
+= DIB_BitmapInfoSize( info
, coloruse
);
219 if (!(logbrush
.lbHatch
= (INT32
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
223 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
224 memcpy( newInfo
, info
, size
);
225 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
226 return CreateBrushIndirect32( &logbrush
);
230 /***********************************************************************
231 * CreateSolidBrush (GDI.66)
233 HBRUSH16 WINAPI
CreateSolidBrush16( COLORREF color
)
235 LOGBRUSH32 logbrush
= { BS_SOLID
, color
, 0 };
236 TRACE(gdi
, "%06lx\n", color
);
237 return CreateBrushIndirect32( &logbrush
);
241 /***********************************************************************
242 * CreateSolidBrush32 (GDI32.64)
244 HBRUSH32 WINAPI
CreateSolidBrush32( COLORREF color
)
246 LOGBRUSH32 logbrush
= { BS_SOLID
, color
, 0 };
247 TRACE(gdi
, "%06lx\n", color
);
248 return CreateBrushIndirect32( &logbrush
);
252 /***********************************************************************
253 * SetBrushOrg (GDI.148)
255 DWORD WINAPI
SetBrushOrg( HDC16 hdc
, INT16 x
, INT16 y
)
258 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
259 if (!dc
) return FALSE
;
260 retval
= dc
->w
.brushOrgX
| (dc
->w
.brushOrgY
<< 16);
267 /***********************************************************************
268 * SetBrushOrgEx (GDI32.308)
270 BOOL32 WINAPI
SetBrushOrgEx( HDC32 hdc
, INT32 x
, INT32 y
, LPPOINT32 oldorg
)
272 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
274 if (!dc
) return FALSE
;
277 oldorg
->x
= dc
->w
.brushOrgX
;
278 oldorg
->y
= dc
->w
.brushOrgY
;
285 /***********************************************************************
286 * FixBrushOrgEx (GDI32.102)
287 * SDK says discontinued, but in Win95 GDI32 this is the same as SetBrushOrgEx
289 BOOL32 WINAPI
FixBrushOrgEx( HDC32 hdc
, INT32 x
, INT32 y
, LPPOINT32 oldorg
)
291 return SetBrushOrgEx(hdc
,x
,y
,oldorg
);
295 /***********************************************************************
298 BOOL32
BRUSH_DeleteObject( HBRUSH16 hbrush
, BRUSHOBJ
* brush
)
300 switch(brush
->logbrush
.lbStyle
)
303 DeleteObject32( (HGDIOBJ32
)brush
->logbrush
.lbHatch
);
306 GlobalFree16( (HGLOBAL16
)brush
->logbrush
.lbHatch
);
309 return GDI_FreeObject( hbrush
);
313 /***********************************************************************
316 INT16
BRUSH_GetObject16( BRUSHOBJ
* brush
, INT16 count
, LPSTR buffer
)
320 logbrush
.lbStyle
= brush
->logbrush
.lbStyle
;
321 logbrush
.lbColor
= brush
->logbrush
.lbColor
;
322 logbrush
.lbHatch
= brush
->logbrush
.lbHatch
;
323 if (count
> sizeof(logbrush
)) count
= sizeof(logbrush
);
324 memcpy( buffer
, &logbrush
, count
);
329 /***********************************************************************
332 INT32
BRUSH_GetObject32( BRUSHOBJ
* brush
, INT32 count
, LPSTR buffer
)
334 if (count
> sizeof(brush
->logbrush
)) count
= sizeof(brush
->logbrush
);
335 memcpy( buffer
, &brush
->logbrush
, count
);
340 /***********************************************************************
341 * SetSolidBrush16 (GDI.604)
343 * If hBrush is a solid brush, change it's color to newColor.
346 * TRUE on success, FALSE on failure.
347 * FIXME: not yet implemented!
349 BOOL16 WINAPI
SetSolidBrush16(HBRUSH16 hBrush
, COLORREF newColor
)
351 FIXME(gdi
, "(hBrush %04x, newColor %04x): stub!\n", hBrush
, (int)newColor
);