Setting General DigitalPaint Information
Several of the DigitalPaint functions provided by LEADTOOLS require additional information, referred to here as DigitalPaint metrics. This information includes:
the Windows device context (DC), such as a screen, used as a display surface.
an optional handle to a bitmap. This bitmap will be used as a painting canvas.
an optional restriction palette to limit the paint colors displayed or painted on the canvas.
These properties can be set using the LRasterPaint::SetMetrics function.
Several of the DigitalPaint functions take a DC as an argument, but can actually paint to a DC and/or a bitmap. If the user supplies only a DC through the function arguments, then the toolkit will paint only to that DC. If the user passes NULL for the DC, but has set a bitmap through the LRasterPaint::SetMetrics function, the painting function will paint only to the bitmap. If the user sets a bitmap and passes a valid DC to a DigitalPaint function, the DigitalPaint function will paint to both the DC and the bitmap. The bitmap can be changed or removed as desired.
The restriction palette controls the colors available to the following groups:
Brush.
Shape.
Fill.
Text.
If a restriction palette is set using this function, then the colors painted to the device context and/or the bitmap are limited to the colors available in the palette. Therefore, if the user tries to paint a color value of RGB(255, 0, 0), which is red, but is using a grayscale restriction palette, the toolkit uses the nearest color to red in the supplied palette. If the color restriction palette is set to NULL, the toolkit will not perform any color restriction.
In addition to the DigitalPaint metrics, other general DigitalPaint information should be set before beginning to paint. This information includes transformation information and device context (DC) boundary information.
The transformation information is used for translating from external coordinates, such as mouse position, to the device context (DC) and/or bitmap coordinates. The current transformation information can be obtained by calling LRasterPaint::GetTransformation. To set the transformation information, call LRasterPaint::SetTransformation.
The device context boundaries should also be set before painting. They should also be updated any time the client area of the display window is resized. To determine the current device context boundaries, call LRasterPaint::GetDCExtents. To set or change the device context boundaries, call LRasterPaint::SetDCExtents.
Once the general DigitalPaint information has been set, painting can begin. For more information on painting, refer to Painting with DigitalPaint.