Bitmap Topics: Using as a Patterned Brush |
|
A pattern brush is one that uses a bitmap or (small) picture to fill out an area. To create DDB bitmap, you can first create an array of WORD values. Then call the CBitmap::CreateBitmap() method to initialize it. As this makes the bitmap ready, call the CBrush::CreatePatternBrush() method to initialize the brush. The syntax of this member function is: BOOL CreatePatternBrush(CBitmap* pBitmap); Once the brush has been defined, you can select in into a device context and use it as you see fit. For example, you can use it to fill a shape. Here is an example:
Another technique you can use to create a pattern brush consists of using a bitmap resource. Before creating a pattern, you must first have a picture, which can be done by creating a bitmap. For example, imagine you create the following bitmap: To create a brush based on a bitmap, you can use the following constructor: CBrush(CBitmap* pBitmap); If you had declared a CBrush variable using the default constructor, you can call the CBrush::CreatePatternBrush() member function to initialize it. Its syntax is: BOOL CreatePatternBrush(CBitmap* pBitmap); Here is an example:
|
|
||
Home | Copyright © 2003-2006 FunctionX, Inc. | |
|