L_PntSetMetrics

#include "LtPnt.h"

L_INT EXT_FUNCTION L_PntSetMetrics(pPaint, UserDC, pBitmap, hRestrictionPalette)

pPAINTHANDLE pPaint;

/* pointer to a paint handle */

HDC UserDC;

/* handle to the device context */

pBITMAPHANDLE pBitmap;

/* pointer to a bitmap handle */

HPALETTE hRestrictionPalette;

/* palette handle */

Sets general painting information for the toolkit.

Parameter

Description

pPaint

Pointer to a paint handle.

UserDC

Handle to a Windows device context (DC), such as a screen, to use as a display surface. This parameter can also be NULL. The mapping mode of the device context must be MM_TEXT. The toolkit will use this DC for future painting compatibility.

pBitmap

Pointer to a bitmap handle that references the bitmap on which the painting will occur. This parameter can be NULL if the user does not need a bitmap. This toolkit uses the LEAD DIB driver, which supports 1, 4, 8, 16 and 24 bit images. If an image that has some other number of bits per pixel is used, L_ColorResBitmap must be used to change the image to a bits per pixel value supported by the LEAD DIB driver.

hRestrictionPalette

Handle to the palette used to restrict the painting colors. This parameter can be NULL. This function makes a copy of the specified palette handle. Therefore, the handle should be deleted after the function returns.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

If the UserDC parameter is NULL, the toolkit will use the screen DC for compatibility issues.

The user should delete UserDC after this function returns.

If hRestrictionPalette is not NULL, painting will be restricted to the nearest colors found in the palette. If hRestrictionPalette is NULL, then no color restriction will be performed by the toolkit.

If pBitmap is not NULL, the toolkit will draw to the bitmap first, then it will draw everything to the device context.

Required DLLs and Libraries

LTPNT

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_PntGetTransformation, L_PntSetTransformation, L_PntGetDCExtents, L_PntSetDCExtents

Topics:

Setting General DigitalPaint Information

 

DigitalPaint Functions: Miscellaneous

Example

L_INT OnPaintShape ( HWND hWnd, pBITMAPHANDLE pBitmap )
{
   pPAINTHANDLE pPaint ;
   HDC          hDC ;
   RECT         rcShapeRect ;
   HPALETTE     hPalette ;

   /* initiate the Paint toolkit */
   if ( SUCCESS != L_PntInit ( &pPaint ) )
   {
      return FAILURE ; 
   }

   /* get the device context */
   hDC = GetDC ( hWnd ) ;

   /* create the palette that we will be used to restrict painting colors to the DC to 
   /* the colors that are in the bitmap */
   hPalette =  L_CreatePaintPalette( hDC, pBitmap ) ;

   /* set the painting metrics */
   L_PntSetMetrics ( pPaint, hDC, pBitmap, hPalette ) ;
   
   /* set the rectangle coordinates with respect to the DC dimensions*/
   SetRect ( &rcShapeRect, 10, 10, 110, 110 ) ;

   /* use the current shape properties to draw an rectangle to DC (hDC) */
   /* and to the currently selected bitmap using the L_PntSetMetrics function */
   L_PntDrawShapeRectangle ( pPaint, hDC, &rcShapeRect ) ; 

   /* release the device context */
   ReleaseDC ( hWnd, hDC ) ;

   /* Delete the newly created palette */
   if ( hPalette )
   {
      DeleteObject ( hPalette ) ;
   }

   /* free the paint tools handle */
   L_PntFree ( pPaint ) ;

   return SUCCESS ;
}