L_PntSetMetrics

Summary

Sets general painting information for the toolkit.

Syntax

#include "LtPnt.h"

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

Parameters

pPAINTHANDLE pPaint

Pointer to a paint handle.

L_HDC 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.

pBITMAPHANDLE 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.

L_HPALETTE 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

Value Meaning
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

See Also

Functions

Topics

Example

L_INT PntSetMetricsExample(HWND hWnd,pBITMAPHANDLE  pBitmap) 
{ 
   L_INT nRet; 
   pPAINTHANDLE pPaint ; 
   HDC          hDC ; 
   RECT         rcShapeRect ; 
   HPALETTE     hPalette ; 
 
   /* initiate the Paint toolkit */ 
   nRet = L_PntInit ( &pPaint ); 
   if ( SUCCESS != nRet ) 
   { 
      return nRet; 
   } 
 
   /* 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 */ 
   nRet = L_PntSetMetrics ( pPaint, hDC, pBitmap, hPalette ) ; 
   if(nRet != SUCCESS) 
      return nRet; 
    
   /* 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 nRet = L_PntSetMetrics function */ 
   L_PntDrawShapeRectangle ( pPaint, hDC, &rcShapeRect ) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* 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 ; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Digital Paint C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.