L_VecPaintDC

#include "ltvkrn.h"

L_LVKRN_API L_INT L_VecPaintDC(hDC, pVector, uWidth, uHeight, pSrc, pSrcClip, pDest, pDestClip, dwFlags)

Displays any vector, at any size, to any device context (screen, printer, or memory dc).

Parameters

L_HDC hDC

Handle to a device context, such as a screen, to use as the display surface. The mapping mode of the device context must be MM_TEXT.

const pVECTORHANDLE pVector

Pointer to the vector handle referencing the vector image to paint.

L_UINT uWidth

Desired virtual width of the source vector in pixels.

L_UINT uHeight

Desired virtual height of the source vector in pixels.

const L_RECT *pSrc

Pointer to the Windows RECT structure that specifies the part of the vector to use as the display source.

The coordinates in the RECT structure are relative to the vector. You can pass NULL to use the default, which matches the vector.

const L_RECT *pSrcClip

Pointer to the Windows RECT structure that specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source vector has changed.

The coordinates in the RECT structure are relative to the vector. You can pass NULL to use the default, which matches the vector.

const L_RECT *pDest

Pointer to the Windows RECT structure that determines how the source rectangle is scaled and how the image is positioned in the device context.

The coordinates in the RECT structure are relative to the device context. There is no default for this parameter. You must specify the RECT structure.

const L_RECT *pDestClip

Pointer to the Windows RECT structure that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

The coordinates in the RECT structure are relative to the device context. You can pass NULL to use the default, which matches the device context. In most cases, however, you should use the rectangle returned by the Windows WM_PAINT message.

L_UINT32 dwFlags

Flag that indicates how to perform the paint process. Possible values are:

Value Meaning
VECTOR_PAINT_ERASEBKGND Use the vector background color to clear the destination area before painting.

Returns

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

Comments

This function emulates the LEAD L_PaintDC function using a vector handle instead of a bitmap image.

Since vector images don't have physical width and height, you must pass width and height values to this function to determine the source size. In L_PaintDC, uWidth and uHeight are equal to Bitmap.Width and Bitmap.Height respectively, also rectangles coordinates should have positive values and they should be relative to uWidth and uHeight.

For more information on using the source and destination rectangles and the clipping rectangles, refer to L_PaintDC.

Required DLLs and Libraries

See Also

Functions

Example

For complete sample code, refer to the VECOVRLY
example.
This example shows the minimum requirements for overlaying a vector drawing over a raster image.

L_LTVKRNTEX_API L_INT VecPaintDCExample( 
   HWND hWnd, 
   BITMAPHANDLE LeadBitmap,   /* Bitmap handle for the image */ 
   VECTORHANDLE LeadVector)   /* Vector handle for the drawing */ 
{ 
   L_INT nRet; 
   HDC hdc;                         /* Device context for the current window */ 
   RECT rLeadDest;                  /* Destination rectangle for painting */ 
   HPALETTE hSavedPalette = NULL;   /* Temporary copy of the current system palette */ 
   HPALETTE hOurPalette = NULL;     /* The palette that we will use to paint */ 
 
   /* Get the device context */ 
   hdc = GetDC( hWnd ); 
 
   /* Set the destination rectangle to be the same as the bitmap. 
   Other painting rectangles can take defaults. */ 
   SetRect( &rLeadDest, 0, 0, BITMAPWIDTH( &LeadBitmap ), BITMAPHEIGHT( &LeadBitmap ) ); 
 
   /* Create the palette that we will use to paint */ 
   hOurPalette = L_CreatePaintPalette( hdc, &LeadBitmap ); 
 
   /* Select our palette and save the old one */ 
   hSavedPalette = SelectPalette( hdc, hOurPalette, FALSE ); 
 
   /* Realize our palette */ 
   RealizePalette( hdc );  
 
   /* Paint the raster image */ 
   nRet = L_PaintDC ( 
      hdc,         /* Device context */ 
      &LeadBitmap, /* Bitmap handle */ 
      NULL,        /* Default source rectangle */ 
      NULL,        /* Default source clip area */ 
      &rLeadDest,  /* Destination rectangle */ 
      NULL,        /* Default destination clipping rectangle */ 
      SRCCOPY );   /*  ROP3 code for a Normal Paint */ 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Overlay the vector image */ 
   nRet = L_VecPaintDC( 
      hdc,               /* Device context */ 
      &LeadVector,       /* Vector handle */ 
      LeadBitmap.Width,  /* Width desired */ 
      LeadBitmap.Height, /* Height desired */ 
      NULL,              /* Default source rectangle */ 
      NULL,              /* Default source clip area */ 
      &rLeadDest,        /* Destination rectangle */ 
      NULL,              /* Default destination clipping rectangle */ 
      0L );              /* Do not erase background */ 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Restore the old palette */ 
   SelectPalette( hdc, hSavedPalette, FALSE ); 
 
   /* Delete the newly created palette */ 
   DeleteObject( hOurPalette ); 
 
   /* Release the device context */ 
   ReleaseDC( hWnd, hdc ); 
   return SUCCESS; 
} 

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.