Setting DigitalPaint Properties

LEADTOOLS DigitalPaint provides several types of painting abilities, including:

image\sqrblit.gif painting using a paintbrush

image\sqrblit.gif painting shapes

image\sqrblit.gif painting a region

image\sqrblit.gif filling an area with paint

image\sqrblit.gif painting text

Each of these is considered a paint "group" and each group has its own set of paint properties that can be set. The values set for these properties control the paint results. For example, these properties determine:

image\sqrblit.gif whether the user draws a line or an ellipse.

image\sqrblit.gif whether the paintbrush contains color or an image.

image\sqrblit.gif how quickly the paint in the paintbrush will fade, if at all.

image\sqrblit.gif the shape of the region to paint.

image\sqrblit.gif the color to use when filling an area.

image\sqrblit.gif the text to paint.

image\sqrblit.gif etc.

Each group of properties has a group-specific structure used for getting or setting the properties. These structures are given below:

PAINTBRUSH

PAINTFILL

PAINTREGION

PAINTSHAPE

PAINTTEXT

Every structure has the dwMask field that will let the user specify the valid fields within the structure. In addition, there are default values for the members of each structure, which will be used if the user does not set paint properties.

To get the current properties for a group, call L_PntGetProperty. This function requires a valid paint handle, the paint group to get, and a pointer to the appropriate group-specific structure. L_PntGetProperty will update the group-specific structure with the current property values.

To set the properties for a group, call L_PntSetProperty. This function requires a valid paint handle, the paint group to set, and a pointer to the appropriate group-specific structure. The structure should contain valid data for setting the properties.

The following is a simple example for setting the shape group properties. (It assumes the paint handle has been initialized.):

//The paint shape structure that will be used to set the shape properties
PAINTSHAPE shape;

//Set the desired shape properties using the field masks
shape.nSize         = sizeof ( PAINTSHAPE ) ;
shape.dwMask    = PSF_BACKGROUNDSTYLE |
                                     PSF_BORDERSTYLE |
                                     PSF_BORDERCOLOR |
                                     PSF_BORDERWIDTH |
                                     PSF_BORDERENDCAP |
                                     PSF_GRADIENTSTYLE |
                                     PSF_GRADIENTSTARTCOLOR |
                                     PSF_GRADIENTENDCOLOR   |
                                     PSF_GRADIENTSTEPS ;

shape.nBackgroundStyle = PAINT_SHAPE_BACK_STYLE_GRADIENT; 
shape.nBorderStyle = PAINT_SHAPE_BORDER_STYLE_DOT ; 
shape.crBorderColor = RGB ( 255, 0, 0 ) ;
shape.nBorderWidth = 10 ;
shape.nBorderEndCap = PAINT_SHAPE_BORDER_ENDCAP_ROUND ; 
shape.nGradientStyle = PAINT_SHAPE_GRADIENT_STYLE_CONE_FROM_L ;
shape.crGradientStartColor= RGB ( 255, 192, 0 ) ; 
shape.crGradientEndColor= RGB ( 0, 0, 255 ) ;
shape.uGradientSteps = 255 ;

//Set the paint shape group properties 
L_PntSetProperty ( pPaint, PAINT_GROUP_SHAPE, &shape ) ;

This example uses the constant PAINT_GROUP_SHAPE to identify the group that will be set. The toolkit has the following group constants:

PAINT_GROUP_BRUSH

PAINT_GROUP_FILL

PAINT_GROUP_REGION

PAINT_GROUP_SHAPE

PAINT_GROUP_TEXT

In addition to setting the paint properties, other information should be set before actually painting. This includes:

image\sqrblit.gif the device context to use for display

image\sqrblit.gif an optional handle to a bitmap to use as a painting canvas

image\sqrblit.gif an optional restriction palette to limit the paint colors displayed or painted on the canvas

These properties are referred to as the DigitalPaint metrics. For more information, refer to Setting General DigitalPaint Information.