4 * Copyright 1993, 1994 Alexandre Julliard
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
);
33 /***********************************************************************
34 * CreateBrushIndirect32 (GDI32.27)
36 HBRUSH32 WINAPI
CreateBrushIndirect32( const LOGBRUSH32
* brush
)
39 HBRUSH32 hbrush
= GDI_AllocObject( sizeof(BRUSHOBJ
), BRUSH_MAGIC
);
40 if (!hbrush
) return 0;
41 brushPtr
= (BRUSHOBJ
*) GDI_HEAP_LOCK( hbrush
);
42 brushPtr
->logbrush
.lbStyle
= brush
->lbStyle
;
43 brushPtr
->logbrush
.lbColor
= brush
->lbColor
;
44 brushPtr
->logbrush
.lbHatch
= brush
->lbHatch
;
45 GDI_HEAP_UNLOCK( hbrush
);
50 /***********************************************************************
51 * CreateHatchBrush16 (GDI.58)
53 HBRUSH16 WINAPI
CreateHatchBrush16( INT16 style
, COLORREF color
)
55 LOGBRUSH32 logbrush
= { BS_HATCHED
, color
, style
};
56 dprintf_gdi(stddeb
, "CreateHatchBrush16: %d %06lx\n", style
, color
);
57 if ((style
< 0) || (style
>= NB_HATCH_STYLES
)) return 0;
58 return CreateBrushIndirect32( &logbrush
);
62 /***********************************************************************
63 * CreateHatchBrush32 (GDI32.48)
65 HBRUSH32 WINAPI
CreateHatchBrush32( INT32 style
, COLORREF color
)
67 LOGBRUSH32 logbrush
= { BS_HATCHED
, color
, style
};
68 dprintf_gdi(stddeb
, "CreateHatchBrush32: %d %06lx\n", style
, color
);
69 if ((style
< 0) || (style
>= NB_HATCH_STYLES
)) return 0;
70 return CreateBrushIndirect32( &logbrush
);
74 /***********************************************************************
75 * CreatePatternBrush16 (GDI.60)
77 HBRUSH16 WINAPI
CreatePatternBrush16( HBITMAP16 hbitmap
)
79 return (HBRUSH16
)CreatePatternBrush32( hbitmap
);
83 /***********************************************************************
84 * CreatePatternBrush32 (GDI32.54)
86 HBRUSH32 WINAPI
CreatePatternBrush32( HBITMAP32 hbitmap
)
88 LOGBRUSH32 logbrush
= { BS_PATTERN
, 0, 0 };
89 BITMAPOBJ
*bmp
, *newbmp
;
91 dprintf_gdi(stddeb
, "CreatePatternBrush: %04x\n", hbitmap
);
93 /* Make a copy of the bitmap */
95 if (!(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
)))
97 logbrush
.lbHatch
= (INT32
)CreateBitmapIndirect16( &bmp
->bitmap
);
98 newbmp
= (BITMAPOBJ
*) GDI_GetObjPtr( (HGDIOBJ32
)logbrush
.lbHatch
,
102 GDI_HEAP_UNLOCK( hbitmap
);
105 TSXCopyArea( display
, bmp
->pixmap
, newbmp
->pixmap
, BITMAP_GC(bmp
),
106 0, 0, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
, 0, 0 );
107 GDI_HEAP_UNLOCK( hbitmap
);
108 GDI_HEAP_UNLOCK( logbrush
.lbHatch
);
109 return CreateBrushIndirect32( &logbrush
);
113 /***********************************************************************
114 * CreateDIBPatternBrush16 (GDI.445)
116 HBRUSH16 WINAPI
CreateDIBPatternBrush16( HGLOBAL16 hbitmap
, UINT16 coloruse
)
118 LOGBRUSH32 logbrush
= { BS_DIBPATTERN
, coloruse
, 0 };
119 BITMAPINFO
*info
, *newInfo
;
122 dprintf_gdi(stddeb
, "CreateDIBPatternBrush: %04x\n", hbitmap
);
124 /* Make a copy of the bitmap */
126 if (!(info
= (BITMAPINFO
*)GlobalLock16( hbitmap
))) return 0;
128 if (info
->bmiHeader
.biCompression
)
129 size
= info
->bmiHeader
.biSizeImage
;
131 size
= (info
->bmiHeader
.biWidth
* info
->bmiHeader
.biBitCount
+ 31) / 32
132 * 8 * info
->bmiHeader
.biHeight
;
133 size
+= DIB_BitmapInfoSize( info
, coloruse
);
135 if (!(logbrush
.lbHatch
= (INT16
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
137 GlobalUnlock16( hbitmap
);
140 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
141 memcpy( newInfo
, info
, size
);
142 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
143 GlobalUnlock16( hbitmap
);
144 return CreateBrushIndirect32( &logbrush
);
148 /***********************************************************************
149 * CreateDIBPatternBrush32 (GDI32.34)
151 HBRUSH32 WINAPI
CreateDIBPatternBrush32( HGLOBAL32 hbitmap
, UINT32 coloruse
)
153 LOGBRUSH32 logbrush
= { BS_DIBPATTERN
, coloruse
, 0 };
154 BITMAPINFO
*info
, *newInfo
;
157 dprintf_gdi(stddeb
, "CreateDIBPatternBrush: %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
= (info
->bmiHeader
.biWidth
* info
->bmiHeader
.biBitCount
+ 31) / 32
167 * 8 * info
->bmiHeader
.biHeight
;
168 size
+= DIB_BitmapInfoSize( info
, coloruse
);
170 if (!(logbrush
.lbHatch
= (INT32
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
172 GlobalUnlock16( hbitmap
);
175 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
176 memcpy( newInfo
, info
, size
);
177 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
178 GlobalUnlock16( hbitmap
);
179 return CreateBrushIndirect32( &logbrush
);
183 /***********************************************************************
184 * CreateSolidBrush (GDI.66)
186 HBRUSH16 WINAPI
CreateSolidBrush16( COLORREF color
)
188 LOGBRUSH32 logbrush
= { BS_SOLID
, color
, 0 };
189 dprintf_gdi(stddeb
, "CreateSolidBrush16: %06lx\n", color
);
190 return CreateBrushIndirect32( &logbrush
);
194 /***********************************************************************
195 * CreateSolidBrush32 (GDI32.64)
197 HBRUSH32 WINAPI
CreateSolidBrush32( COLORREF color
)
199 LOGBRUSH32 logbrush
= { BS_SOLID
, color
, 0 };
200 dprintf_gdi(stddeb
, "CreateSolidBrush32: %06lx\n", color
);
201 return CreateBrushIndirect32( &logbrush
);
205 /***********************************************************************
206 * SetBrushOrg (GDI.148)
208 DWORD WINAPI
SetBrushOrg( HDC16 hdc
, INT16 x
, INT16 y
)
211 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
212 if (!dc
) return FALSE
;
213 retval
= dc
->w
.brushOrgX
| (dc
->w
.brushOrgY
<< 16);
220 /***********************************************************************
221 * SetBrushOrgEx (GDI32.308)
223 BOOL32 WINAPI
SetBrushOrgEx( HDC32 hdc
, INT32 x
, INT32 y
, LPPOINT32 oldorg
)
225 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
227 if (!dc
) return FALSE
;
230 oldorg
->x
= dc
->w
.brushOrgX
;
231 oldorg
->y
= dc
->w
.brushOrgY
;
238 /***********************************************************************
239 * FixBrushOrgEx (GDI32.102)
240 * SDK says discontinued, but in Win95 GDI32 this is the same as SetBrushOrgEx
242 BOOL32 WINAPI
FixBrushOrgEx( HDC32 hdc
, INT32 x
, INT32 y
, LPPOINT32 oldorg
)
244 return SetBrushOrgEx(hdc
,x
,y
,oldorg
);
248 /***********************************************************************
251 BOOL32
BRUSH_DeleteObject( HBRUSH16 hbrush
, BRUSHOBJ
* brush
)
253 switch(brush
->logbrush
.lbStyle
)
256 DeleteObject32( (HGDIOBJ32
)brush
->logbrush
.lbHatch
);
259 GlobalFree16( (HGLOBAL16
)brush
->logbrush
.lbHatch
);
262 return GDI_FreeObject( hbrush
);
266 /***********************************************************************
269 INT16
BRUSH_GetObject16( BRUSHOBJ
* brush
, INT16 count
, LPSTR buffer
)
273 logbrush
.lbStyle
= brush
->logbrush
.lbStyle
;
274 logbrush
.lbColor
= brush
->logbrush
.lbColor
;
275 logbrush
.lbHatch
= brush
->logbrush
.lbHatch
;
276 if (count
> sizeof(logbrush
)) count
= sizeof(logbrush
);
277 memcpy( buffer
, &logbrush
, count
);
282 /***********************************************************************
285 INT32
BRUSH_GetObject32( BRUSHOBJ
* brush
, INT32 count
, LPSTR buffer
)
287 if (count
> sizeof(brush
->logbrush
)) count
= sizeof(brush
->logbrush
);
288 memcpy( buffer
, &brush
->logbrush
, count
);