LRasterPaint::SetMetrics

#include "Ltwrappr.h"

L_INT LRasterPaint::SetMetrics(UserDC, pBitmap, hRestrictionPalette)

Sets general painting information for the toolkit.

Parameters

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, LBitmapBase::ColorRes must be used to change the image to a bits per pixel value supported by the LEAD DIB driver.

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 LRasterPaint_SetMetricsExample( CWnd * pWnd, LBitmap* pBitmap ) 
 
{ 
   L_INT          nRet; 
   LRasterPaint   rstp ; 
   CDC*           pDC = pWnd->GetDC() ; 
   RECT           rcShapeRect ; 
   HPALETTE       hPalette ; 
 
   /* initiate the Paint toolkit */ 
   nRet = rstp.Initialize (); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* create the palette that we will be used to restrict painting colors to the DC to  
   /* the colors that are in the bitmap */ 
   hPalette = pBitmap->CreatePaintPalette( pDC->m_hDC ) ; 
 
   /* set the painting metrics */ 
   nRet = rstp.SetMetrics ( pDC->m_hDC, pBitmap->GetHandle(), 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 */ 
   /* and to the currently selected bitmap using the LRasterPaint::SetMetrics function */ 
   nRet = rstp.DrawShapeRectangle ( pDC->m_hDC, &rcShapeRect ) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Delete the newly created palette */ 
   if ( hPalette ) 
   { 
      DeleteObject ( hPalette ) ; 
   } 
 
   /* free the paint tools handle */ 
   nRet = rstp.Free () ; 
   if(nRet != SUCCESS) 
      return nRet; 
 
   pWnd->ReleaseDC( pDC ) ; 
 
   return SUCCESS ; 
} 
Help Version 21.0.2021.3.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DigitalPaint C++ Class Library Help