Painting With a Brush

The LEADTOOLS LRasterPaint class provides the following functions for painting with a brush:

LRasterPaint::BrushMoveTo

LRasterPaint::BrushLineTo

These functions require:

The LRasterPaint::BrushMoveTo function paints a single brush touch using the current brush group properties at the required position. The LRasterPaint::BrushLineTo function paints a series of brush touches (a brush stroke) from the point set by the LRasterPaint::BrushMoveTo function, to the position set by the LRasterPaint::BrushLineTo function. If LRasterPaint::BrushMoveTo is not called before calling LRasterPaint::BrushLineTo, the LRasterPaint::BrushLineTo 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 LRasterPaint::GetProperty. To set or change the current brush properties, call LRasterPaint::SetProperty. 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 LRasterPaint::SetMetrics function.

Any transformation information should be set, using the LRasterPaint::SetTransformation function before calling any brush or other painting function. To get the current transformation information, call LRasterPaint::GetTransformation.

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 */   
// Assume Paint was constructed from LRasterPaint class   
Paint.SetProperty ( PAINT_GROUP_BRUSH, &brush ) ;   
/* Use the current paintbruch properties to draw a paintbrush stroke to DC (hDC) */   
Paint.BrushMoveTo ( hDC, 10, 10 ) ;   
Paint.BrushLineTo ( hDC, 100, 100 ) ;   
/* Release the device context */   
ReleaseDC ( hWnd, hDC ) ; 

Help Version 22.0.2021.8.20
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DigitalPaint C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.