Filling an Area

LEADTOOLS DigitalPaint provides the following functions for filling an area:

L_PntFillSurface

L_PntFillBorder

L_PntFillColorReplace

These functions require:

These functions will fill areas based on the current fill properties. To determine the current fill properties, call L_PntGetProperty. To set or change the current fill properties, call L_PntSetProperty. For more information on the fill properties, refer to the PAINTFILL structure.

The filling functions use different methods to fill an area. The L_PntFillSurface function fills an area, starting at a specified point and continuing in all directions, that contains a specified color, falling within some tolerance range. The upper and lower tolerances are set in the PAINTFILL structure. The L_PntFillBorder function fills an area, starting at a specified point and continuing in all directions, until it finds a specified color, falling within some tolerance range. The L_PntFillColorReplace will replace every pixel using the current fill properties.

Any transformation information should be set, using the L_PntSetTransformation function before calling any fill or other painting function. To get the current transformation information, call L_PntGetTransformation.

For selecting a color from a specific point, call L_PntPickColor.

The following example sets the device context boundaries, sets the fill properties, sets the DigitalPaint metrics properties and then performs a color replacement. It assumes the paint handle has been initialized, and the window handle and lead bitmap handle are valid:

HDC          hDC ;   
PAINTFILL fill ;   
RECT         rcDCExtents ;   
/* Get device context to draw on */   
hDC = GetDC ( hWnd ) ;   
/* Get the destination DC dimensions */     
GetClientRect ( hWnd, &rcDCExtents ) ;   
/* Set the toolkit user DC extents */   
L_PntSetDCExtents ( pPaint, &rcDCExtents ) ;   
/* Set the required fill properties */   
fill.nSize  = sizeof ( PAINTFILL ) ;   
fill.dwMask = PFF_STYLE ;   
fill.nStyle = PAINT_FILL_STYLE_GRADIENT ;   
/* Set the new fill properties */   
L_PntSetProperty ( pPaint, PAINT_GROUP_FILL, &fill ) ;   
/*Select the bitmap into the paint handle*/   
L_PntSetMetrics ( pPaint, NULL, &hLeadBitmap, NULL ) ;   
/* Fill the target area in the DC (hDC) and the currently selected bitmap*/   
L_PntFillColorReplace ( pPaint, hDC, RGB ( 255, 0, 0 ) ) ;    
/* Release the device context */   
ReleaseDC ( hWnd, hDC ) ; 

This example uses the function L_PntSetDCExtents. This function is essential in filling the desired area. The user should define the boundaries of the DC supplied to the fill function. The supplied dimensions will be in pixels. To get the DC boundaries previously set, call the L_PntGetDCExtents function.

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

LEADTOOLS Digital Paint C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.