Low-Level DigitalPaint: Setting General DigitalPaint Information

Start with the project you created in Low-Level DigitalPaint: Initializing and Freeing a Paint Handle. This tutorial will let you add code to set DigitalPaint information such as transformation, device context, bitmap canvas and restriction palette information.

  1. Add the following declarations to the WndProc function:
    static PAINTXFORM PntXForm ;   
     RECT rcDCRect ; 
  2. Add this line after the hDC = GetDC( hWnd); function call in the "case IDM_FILE_OPEN:" option of the WM_COMMAND message in the WndProc function:
    hPalette = L_CreatePaintPalette( hDC, &hBitmap ) ; 
    L_PntSetMetrics ( pPaint, hDC, &hBitmap, hPalette ) ; 
    DeleteObject(hPalette); 
  3. Declare the following variable in the "case IDM_FILE_OPEN:" option of the WM_COMMAND message in the WndProc function: right after
    HDC hDC; 
    HPALETTE hPalette; 
  4. Add the following code after the OnSize function call in the WM_SIZE message in the WndProc function:
    // set the toolkit transformations.   
    PntXForm.nZoom    = nZoomFactor ;   
    PntXForm.nXOffset = - rcView.left ;   
    PntXForm.nYOffset = - rcView.top ;   
    L_PntSetTransformation ( pPaint, &PntXForm ) ;   
    // set the device context boundaries   
    SetRect ( &rcDCRect, 0, 0, LOWORD ( lParam ), HIWORD ( lParam ) ) ;   
    L_PntSetDCExtents ( pPaint, &rcDCRect ) ; 
  5. Add the following code after the OnHScroll function call in the WM_HSCROLL message in the WndProc function:
    // set the toolkit transformations.   
    PntXForm.nZoom    = nZoomFactor ;   
    PntXForm.nXOffset = - rcView.left ;   
    PntXForm.nYOffset = - rcView.top ;   
    L_PntSetTransformation ( pPaint, &PntXForm ) ; 
  6. Add the following code after the OnVScroll function call in the WM_VSCROLL message in the WndProc function:
    // set the toolkit transformations.   
    PntXForm.nZoom    = nZoomFactor ;   
    PntXForm.nXOffset = - rcView.left ;   
    PntXForm.nYOffset = - rcView.top ;   
    L_PntSetTransformation ( pPaint, &PntXForm ) ; 
  7. Compile and run the project by selecting Build->Execute tutorial.exe from the menu.
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