diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-EF49C43F-E9ED-5B4D-B9C4-376B9A4E3FA6.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-EF49C43F-E9ED-5B4D-B9C4-376B9A4E3FA6.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,25 @@ + + + + + +Using a Bitmap-Patterned Brush

If the brush style is set to a patterned brush, then a bitmap can be used for filling shapes. The following example code illustrate how this is done. The bitmap is tiled around the given origin - the top left of the window is the default - and clipped to the given shape. The second bitmapped brush example shows the effect of moving the origin.

Using a bitmap patterned brush, with the default origin
  1. Load the bitmap file in the standard way.

  2. Use the bitmap as the graphics context’s brush pattern.

  3. Set the brush style to TBrushStyle::EPatternedBrush.

  4. Discard the brush pattern using DiscardBrushPattern().

  5. Destroy the bitmap.

With no brush origin set, the tiling pattern starts at the top left corner of the window.

CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); +CleanupStack::PushL(bitmap); +User::LeaveIfError(bitmap->Load(KAnMbmFile,KABitmapID)); +// set brush pattern and style to use the bitmap +gc.UseBrushPattern(bitmap); +gc.SetBrushStyle(CGraphicsContext::EPatternedBrush); +// draw shape filled with bitmap pattern +gc.DrawRect(rect); +gc.DiscardBrushPattern(); +CleanupStack::PopAndDestroy();
Using a bitmap patterned brush, with a set origin

You can set the brush origin using SetBrushOrigin(), and tile the bitmap around this point.

The example code is exactly the same as that in previous bitmapped brush example, except that the following line is added before the rectangle is drawn:

... +TPoint pos(100,100); +gc.SetBrushOrigin(pos); +...

For using bitmaps, see BitGDI Component.

Drawing + to a Graphics Context Tutorials Drawing and Graphics Contexts
\ No newline at end of file