L_VecRealize

#include "lvkrn.h"

L_LVKRN_API L_INT L_VecRealize(pBitmap, pVector, bEraseBkgnd)

pBITMAPHANDLE pBitmap;

pointer to a bitmap handle

const pVECTORHANDLE pVector;

pointer to a vector handle

L_BOOL bEraseBkgnd;

flag that indicates whether to erase the background

Draws the specified vector into the specified LEAD bitmap handle.

Parameter Description
pBitmap Pointer to a bitmap handle, into which the vector will be drawn.
pVector Pointer to a vector handle that references the vector to be drawn into pBitmap.
bEraseBkgnd Flag that indicates whether or not to erase the background rectangle when realizing the vector to the bitmap. Possible values are:
  Value Meaning
  TRUE The background rectangle will be erased when the vector image is realized to the bitmap.
  FALSE The background rectangle will not be erased.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function draws the specified vector into the specified bitmap handle.

The bitmap handle should be allocated before calling this function.

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

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

This function will use the current camera and current view port of the vector handle to do the necessary projection onto the surface of the DC.

Required DLLs and Libraries

LVKRN

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_VecPaint, L_VecAttachToWindow, L_VecSetCamera, L_VecSetViewport, L_VecSetBackgroundColor

Example

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

pBITMAPHANDLE VecRealizeExample( 
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; 
   pBITMAPHANDLE pBitmap; 
   L_DOUBLE Width, Height, Factor; 
   RECT rect; 
   /* 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 vector image 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 LEAD bitmap */ 
   pBitmap = (pBITMAPHANDLE) GlobalAllocPtr(GHND, sizeof( BITMAPHANDLE )); 
   *nRet = L_InitBitmap( pBitmap, sizeof( BITMAPHANDLE ), rect.right, rect.bottom, 24 ); 
   if (*nRet != SUCCESS) 
      return NULL; 
   *nRet = L_AllocateBitmap( pBitmap, TYPE_CONV ); 
   if (*nRet != SUCCESS) 
      return NULL; 
   /* set the viewport */ 
   *nRet = L_VecSetViewport( &TmpVector, &rect ); 
   if(*nRet != SUCCESS) 
      return NULL; 
   /* set the camera to a top view position. */ 
   *nRet = L_VecSetCamera( &TmpVector, NULL ); 
   if(*nRet != SUCCESS) 
      return NULL; 
   /* Render the vector into the bitmap */ 
   *nRet = L_VecRealize( pBitmap, &TmpVector, TRUE ); 
   if(*nRet != SUCCESS) 
      return NULL; 
   /* Free the vector cause it's no longer needed */ 
   *nRet = L_VecFree( &TmpVector ); 
   if(*nRet != SUCCESS) 
      return NULL; 
   return pBitmap; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Vector C API Help