Brush Support

DIB_RealizeObject converts logical drawing objects to physical drawing objects. For brushes, the logical brush structure, LOGBRUSH, has two colors in it, lbColor and lbBkColor. The member lbColor is a logical color. This is the color that the display driver should use to generate a solid brush. Since the display driver may not be able to directly support this logical color (for example, it might not be one of the 16 colors that a driver running in 16 color mode can support), it should create a dither pattern that closely approximates this color. From GDI's perspective, this is still a solid brush because the brush style lbStyle is BS_SOLID.

Brushes have three sections: the color part, the monochrome part, and the transparency mask (which is used with hatched brushes). The color part is used to draw on the screen or DDB, and the monochrome part is used to draw on old-style monochrome bitmaps.

The member lbBkColor is only used when a hatched brush is realized. The lbBkColor member is a physical color that has been previously converted from logical to physical with a call to DIB_ColorInfo.

When the DIB Engine realizes a hatched brush, it maps all 1 bits in the pattern to the foreground color and all 0 bits in the pattern to the background color and puts the results into the dp8BrushBits member of the DIB_Brush8 structure. During realization the DIB engine also converts the logical foreground color into a physical color and stores it into dp8FgColor member. The DIB engine does this so that drivers that have hardware acceleration can draw fast hatched brushes by loading the color in dp8FgColor into their foreground color register, loading the color in dp8BgColor into their background color register, and then drawing with the bit pattern in the dp8BrushMask portion of the brush. Common video hardware has color expand capability that will automatically map the 1 bits to the contents of their foreground color register and the 0 bits to the contents of their background color register.

In summary, the dp8FgColor member contains a logical color if the brush style is BS_SOLID or BS_PATTERN (although it is not used for pattern brushes). If the brush style is BS_HATCHED, dp8FgColor contains a physical color. The dp8BgColor member is only used with BS_HATCHED style brushes and it is a physical color.

See also DIB_Brush