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  L_CreatePaintPalette function call in the "case IDM_FILE_OPEN:" option of the WM_COMMAND message in the WndProc function:

 

L_PntSetMetrics ( pPaint, hDC, &hBitmap, hPalette ) ;

 

3.

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 ) ;

 

4.

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 ) ;

 

5.

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 ) ;

 

6.

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