CreateDIBPatternBrush

Version 3.0

Syntax

HBRUSH CreateDIBPatternBrush(hPackedDIB,wUsage)

This function creates a logical brush that has the pattern specified by the device-independent bitmap (DIB) defined by the the hPackedDIB parameter. The brush can subsequently be selected for any device that supports raster operations. For more information, see the RC_BITBLT raster capability in the GetDeviceCaps function, later in this chapter.

Parameter Type/Description  
hPackedDIB GLOBALHANDLE Identifies a global memory object containing a packed device-independent bitmap. To obtain this handle, an application calls the GlobalAlloc function to allocate a block of global memory and then fills the memory with the packed DIB. A packed DIB consists of a BITMAPINFO data structure immediately followed by the array of bytes which define the pixels of the bitmap.  
wUsage WORD Specifies whether the bmiColors[] fields of the BITMAPINFO data structure contain explicit RGB values or indexes into the currently realized logical palette. The wUsage parameter must be one of the following values:  
  Value Meaning
  DIB_PAL_COLORS The color table contains literal RGB values. into the currently realized logical palette.
  DIB_RGB_COLORS The color table consists of an array of 16-bit indexes.

Return Value

The return value identifies a logical brush if the function is successful. Otherwise, it is NULL.

Comments

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 background and foreground 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 foreground color, and pixels mapped to the second color (at offset 1 in the color table) are displayed using the background color. The SetTextColor and SetBkColor functions change the foreground and background colors, respectively, for a device context.