diff -r ebc84c812384 -r 46218c8b8afa Symbian3/PDK/Source/GUID-EF49C43F-E9ED-5B4D-B9C4-376B9A4E3FA6.dita --- a/Symbian3/PDK/Source/GUID-EF49C43F-E9ED-5B4D-B9C4-376B9A4E3FA6.dita Thu Mar 11 15:24:26 2010 +0000 +++ b/Symbian3/PDK/Source/GUID-EF49C43F-E9ED-5B4D-B9C4-376B9A4E3FA6.dita Thu Mar 11 18:02:22 2010 +0000 @@ -1,25 +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 + + + + + +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