Low-Level DigitalPaint: Creating a Region

Start with the project you created in Low-Level DigitalPaint: Painting Using a Shape.

1. Add the following item to the popup menu "Painting Test " that you added to the main menu:
  &Painting Test  
  &Region with ID = IDM_PAINTTEST_REGION
2. Add the following function before the OnOpen function definition:

 

static L_VOID OnRegion ( HWND hWnd, pPAINTHANDLE pPaint ) 
{ 
   HDC hDC ; 
   PAINTREGION region ; 
   RECT rcRegion ; 
   HRGN hRgn ; 
   region.nSize = sizeof ( PAINTREGION ) ; 
   region.dwMask = PRF_ROUNDRECTELLIPSEWIDTH | 
   PRF_ROUNDRECTELLIPSEHEIGHT ; 
   region.nRoundRectEllipseWidth = 40 ; 
   region.nRoundRectEllipseHeight = 40 ; 
   // Set the new region properties 
   L_PntSetProperty ( pPaint, PAINT_GROUP_REGION, &region ) ; 
   // Get the device context 
   hDC = GetDC ( hWnd ) ; 
   // Set the coordinates with respect to the DC dimensions 
   SetRect ( &rcRegion, 10, 10, 200, 200 ) ; 
   // Use the current region properties and the current painting 
   // transformations to create a rouned rectangle region 
   L_PntRegionRoundRect ( pPaint, hDC, &rcRegion, &hRgn ) ; 
   // View the resulted region 
   FrameRgn ( hDC, hRgn, (HBRUSH)GetStockObject ( BLACK_BRUSH ), 1, 1 ) ; 
    
   // Delete the region 
   DeleteObject ( hRgn ) ; 
   // Release the device context 
   ReleaseDC ( hWnd, hDC ) ; 
} 

3.

Add the following line after the "return 0L ;" of the "case IDM_PAINTTEST_SHAPE:" statement:

case IDM_PAINTTEST_REGION:   
OnRegion ( hWnd, pPaint ) ;   
return 0L ; 

4.

Compile and run the project by selecting Build->Execute tutorial.exe from the menu.

5.

Go to the "File" menu and use the "Open" item to open an image.

6.

Go to the "Painting Test" and select the "Region" item. This will create a region using the current region properties.

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Digital Paint C API Help