Low-Level DigitalPaint: Painting a Shape

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

  1. Add the following item to the popup menu "Painting Test " that you added to the main menu:
    • &Painting Test
    • &Shape with ID = IDM_PAINTTEST_SHAPE
  2. Add the following function before the OnOpen function definition:
    static L_VOID OnShape ( HWND hWnd, pPAINTHANDLE pPaint ) 
    { 
       HDC hDC ; 
       PAINTSHAPE shape; 
       // Set the required shape properties 
       shape.nSize  = sizeof ( PAINTSHAPE ) ; 
       shape.dwMask = PSF_BORDERWIDTH | 
       PSF_BORDERSTYLE | 
       PSF_BORDERCOLOR | 
       PSF_BORDERENDCAP ; 
       shape.nBorderWidth  = 10 ; 
       shape.nBorderStyle  = PAINT_SHAPE_BORDER_STYLE_DASHDOT ; 
       shape.crBorderColor = RGB ( 255, 0, 0 ) ; 
       shape.nBorderEndCap = PAINT_SHAPE_BORDER_ENDCAP_ROUND ; 
       // Set the new shape properties 
       L_PntSetProperty ( pPaint, PAINT_GROUP_SHAPE, &shape ) ; 
       // Get device context to draw on 
       hDC = GetDC ( hWnd ) ; 
       // Use the current shape properties to draw a line to the currently selected bitmap 
       L_PntDrawShapeLine ( pPaint, hDC, 10, 10, 400, 400 ) ; 
       // Release the device context 
       ReleaseDC ( hWnd, hDC ) ; 
    } 
  3. Add the following line after the "return 0L ;" of the "case IDM_PAINTTEST_BRUSH:" statement:

    case IDM_PAINTTEST_SHAPE:   
         OnShape ( 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 "Shape" item. This will draw a line using the current shape properties.
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Digital Paint C API Help