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.
Load the bitmap file in the standard way.
Use the bitmap as the graphics context’s brush pattern.
Set the brush style to TBrushStyle::EPatternedBrush .
Discard the brush pattern using DiscardBrushPattern() .
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();
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 .
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.