L_VecPaint

#include "ltvkrn.h"

L_LVKRN_API L_INT L_VecPaint(hDC, pVector, bEraseBkgnd)

Draws the specified vector into a given device context.

Parameters

L_HDC hDC

Device context.

const pVECTORHANDLE pVector

Pointer to a vector handle that references the vector to draw.

L_BOOL bEraseBkgnd

Flag that indicates whether or not to erase the background rectangle when rendering the vector. Possible values are:

Value Meaning
TRUE The background rectangle will be erased when the vector image is rendered to the device context.
FALSE The background rectangle will not be erased.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

If hDC is NULL, this function will assume that pVector is already attached to a window, and will draw the vector image to the window DC.

The background color used to erase the rectangle where the vector image is rendered can be set with L_VecSetBackgroundColor.

If L_VecPaint is called in response to a WM_PAINT message, hDC should be the paint DC obtained from BeginPaint.

This function will use current camera and current viewport of the vector handle to do the necessary projection into the surface of the DC.

Required DLLs and Libraries

See Also

Functions

Example

This example will create a HBITMAP for the given vector file.

L_LTVKRNTEX_API HBITMAP VecPaintExample( 
   L_TCHAR* pszFile, 
   L_UINT uWidth, 
   L_UINT uHeight, 
   L_INT* nRet) 
{ 
   /* uWidth and uHeight are the desired bitmap size, the final bitmap size will be less or equal to uWidth and uHeight. */ 
   VECTORHANDLE TmpVector; 
   VECTORPOINT min, max; 
   HBITMAP hBitmap; 
   L_DOUBLE Width, Height, Factor; 
   RECT rect; 
   HDC hDC; 
 
   /* First load the vector */ 
   *nRet = L_VecLoadFile( pszFile, &TmpVector, NULL, NULL ); 
   if(*nRet != SUCCESS) 
      return NULL; 
 
   /* Get vector image logical parallelogram */ 
   *nRet = L_VecGetObjectParallelogram( &TmpVector, NULL, &min, &max, 0L ); 
   if(*nRet != SUCCESS) 
      return NULL; 
 
   /* Calculate viewport preserving drawing aspect ratio */ 
   Width  = max.x - min.x; 
   Height = max.y - min.y; 
    
   if( uWidth < uHeight ) 
   { 
      Factor =  uWidth / Width; 
 
      /* Check if height would fit in size */ 
      if( ( Factor * Height ) > uHeight ) 
      { 
         /* No can do, calculate based on height */ 
         Factor = uHeight / Height; 
      } 
   } 
   else 
   { 
      Factor = uHeight / Height; 
 
      /* Check if width would fit in size */ 
      if( ( Factor * Width ) > uWidth ) 
      { 
            /* No can do, calculate based on width */ 
            Factor = uWidth / Width; 
      } 
   } 
 
   /* Setup viewport rectangle */ 
   rect.left   = 0; 
   rect.top    = 0; 
   rect.right  = (L_INT) ( Factor * Width ); 
   rect.bottom = (L_INT) ( Factor * Height ); 
 
   /* Create the DDB */ 
   hBitmap = CreateCompatibleBitmap( NULL, rect.right, rect.bottom ); 
   hDC = CreateCompatibleDC( NULL ); 
   SelectObject( hDC, hBitmap ); 
 
   /* Setup viewport */ 
   *nRet = L_VecSetViewport( &TmpVector, &rect ); 
   if(*nRet != SUCCESS) 
      return NULL; 
 
   /* Setup default camera (Top view) */ 
   *nRet = L_VecSetCamera( &TmpVector, NULL ); 
   if(*nRet != SUCCESS) 
      return NULL; 
  
   /* Render the vector into the memory DC with black background */ 
   *nRet = L_VecSetBackgroundColor( &TmpVector, RGB( 0, 0, 0 ) ); 
   if(*nRet != SUCCESS) 
      return NULL; 
 
   *nRet = L_VecPaint( hDC, &TmpVector, TRUE ); 
   if(*nRet != SUCCESS) 
      return NULL; 
 
   DeleteDC( hDC ); 
 
   /* Free the vector cause it's no longer needed */ 
   *nRet = L_VecFree( &TmpVector ); 
 
   return hBitmap; 
} 

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

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