CBrush::CreateDIBPatternBrush

BOOL CreateDIBPatternBrush( HGLOBAL hPackedDIB, UINT nUsage );

BOOL CreateDIBPatternBrush( const void* lpPackedDIB, UINT nUsage );

Return Value

Nonzero if successful; otherwise 0.

Parameters

hPackedDIB

Identifies a global-memory object containing a packed device-independent bitmap (DIB).

nUsage

Specifies whether the bmiColors[] fields of the BITMAPINFO data structure (a part of the “packed DIB”) contain explicit RGB values or indices into the currently realized logical palette. The parameter must be one of the following values:

lpPackedDIB

Points to a packed DIB consisting of a BITMAPINFO structure immediately followed by an array of bytes defining the pixels of the bitmap.

Remarks

Initializes a brush with the pattern specified by a device-independent bitmap (DIB). The brush can subsequently be selected for any device context that supports raster operations.

The two versions differ in the way you handle the DIB:

A packed DIB consists of a BITMAPINFO data structure immediately followed by the array of bytes that defines the pixels of the bitmap. Bitmaps used as fill patterns should be 8 pixels by 8 pixels. If the bitmap is larger, Windows creates a fill pattern using only the bits corresponding to the first 8 rows and 8 columns of pixels in the upper-left corner of the bitmap.

When an application selects a two-color DIB pattern brush into a monochrome device context, Windows ignores the colors specified in the DIB and instead displays the pattern brush using the current text and background colors of the device context. Pixels mapped to the first color (at offset 0 in the DIB color table) of the DIB are displayed using the text color. Pixels mapped to the second color (at offset 1 in the color table) are displayed using the background color.

For information about using the following Windows functions, see the Win32 SDK Programmer’s Reference:

CBrush OverviewClass MembersHierarchy Chart

See Also   CBrush::CreatePatternBrush, CBrush::CreateBrushIndirect, CBrush::CreateSolidBrush, CBrush::CreateHatchBrush, CGdiObject::CreateStockObject, CDC::SelectObject, CGdiObject::DeleteObject, CDC::GetBrushOrg, CDC::SetBrushOrg