LEADTOOLS DigitalPaint provides the following functions for painting with a brush:
These functions require:
a valid paint handle.
an optional windows device context.
X coordinate of a point.
Y coordinate of a point.
The L_PntBrushMoveTo function paints a single brush touch using the current brush group properties at the required position. The L_PntBrushLineTo function paints a series of brush touches (a brush stroke) from the point set by the L_PntBrushMoveTo function, to the position set by the L_PntBrushLineTo function. If L_PntBrushMoveTo is not called before calling L_PntBrushLineTo, the L_PntBrushLineTo function will use the default (0, 0) as the starting point for the line.
These functions will draw brush touches and strokes based on the current brush properties. To determine the current brush properties, call L_PntGetProperty. To set or change the current brush properties, call L_PntSetProperty. For more information on the brush properties, refer to the PAINTBRUSH structure.
Before painting a brush touch or a brush stroke, set the DigitalPaint metrics using the L_PntSetMetrics function.
Any transformation information should be set, using the L_PntSetTransformation function before calling any brush or other painting function. To get the current transformation information, call L_PntGetTransformation.
The following example sets the brush properties, moves the paintbrush to a certain point and then paints a brush stroke. It assumes the paint handle has been initialized and the window handle is valid:
HDC hDC;
PAINTBRUSH brush;
/* Get device context to draw on */
hDC = GetDC ( hWnd ) ;
/* Set the required paintbrush properties */
brush.nSize = sizeof ( PAINTBRUSH ) ;
brush.dwMask = PBF_DIAMETER |
PBF_TOUCH |
PBF_SPACING ;
brush.nDiameter = 20 ;
brush.Touch.crColor = RGB ( 255, 0, 0 ) ;
brush.nSpacing = 25 ;
/* Set the new paintbruch properties */
L_PntSetProperty ( pPaint, PAINT_GROUP_BRUSH, &brush ) ;
/* Use the current paintbruch properties to draw a paintbrush stroke to DC (hDC) */
L_PntBrushMoveTo ( pPaint, hDC, 10, 10 ) ;
L_PntBrushLineTo ( pPaint, hDC, 100, 100 ) ;
/* Release the device context */
ReleaseDC ( hWnd, hDC ) ;