LBitmapRgn::SetRgnPolygon

Summary

Creates or updates the associated class object's bitmap region by adding a polygonal region.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmapRgn::SetRgnPolygon(pPoints, uPoints, uFillMode=L_POLY_WINDING)

Parameters

POINT * pPoints

Pointer to an array of POINT structures. The points in the array must be in the order in which the vertices of the polygon are connected. To create the line that closes the polygon, the last point in the array is connected to the first point of the array.

L_UINT uPoints

The number of points in the array specified by the pPoints parameter.

L_UINT uFillMode

Flag that indicates how to handle complex crossing lines. The following are valid values, which are illustrated below:

Value Meaning
L_POLY_WINDING [0] All pixels that are inside the resulting exterior lines are in the region.
L_POLY_ALTERNATE [1] The region includes the area between odd-numbered and even-numbered polygon sides on each scan line.
image\winding.gif

Returns

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

Comments

To update an existing region, you specify how the new region is to be combined with the existing one. For descriptions of the possibilities, refer to Creating a Bitmap Region.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LBitmapRgn__SetRgnPolygonExample(HWND hWnd)  
{ 
    
   RGNXFORM XFormBtmp; // Structure for transforming display coordinates  
   RECT rClientArea; // Client area of the current window 
   L_INT nRet = 0; 
   LBitmapRgn lBmpRgn ; 
   LBitmapBase BmpBase; 
   LBitmapBase BmpMask; 
   HRGN hRgn ; 
   POINT PolyPt[5]; // Array of points that defines the polygon  
   POINT *pPolyPt = PolyPt; // Pointer to the array of points  
 
   // Get the client area of the current window 
   GetClientRect(hWnd,&rClientArea); 
 
   // Load a bitmap  
   nRet = BmpBase.Load(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), 32, ORDER_BGR); 
   if (nRet == SUCCESS) 
   { 
      lBmpRgn.SetBitmap(&BmpBase) ;    
 
      L_UINT uCombineMode = lBmpRgn.GetRgnCombineMode() ; 
      uCombineMode |= L_RGN_OR ; 
 
      lBmpRgn.SetRgnCombineMode(uCombineMode) ; 
      nRet =lBmpRgn.SetRgnColor(RGB(0,0,0)) ; 
      if(nRet !=SUCCESS) 
         return nRet; 
 
      // create mask region from bitmap 
      nRet = lBmpRgn.CreateMaskFromBitmapRgn(&BmpMask, sizeof(BITMAPHANDLE)) ; 
      if (nRet == SUCCESS) 
      { 
         // set region from mask bitmap 
         lBmpRgn.SetRgnFromMask(BmpMask) ; 
      } 
      else 
         return nRet; 
 
      // get the region transform used with region function 
      lBmpRgn.GetRgnXForm(&XFormBtmp) ; 
 
      /* Set RGNXFORM fields, assuming that the display rectangle is the same 
      as the client area of the current window */ 
      XFormBtmp.uViewPerspective = TOP_LEFT; 
      XFormBtmp.nXScalarNum = BmpBase.GetWidth(); 
      XFormBtmp.nXScalarDen = rClientArea.right; 
      XFormBtmp.nYScalarNum = BmpBase.GetHeight() ; 
      XFormBtmp.nYScalarDen = rClientArea.bottom; 
      XFormBtmp.nXOffset = 0; 
      XFormBtmp.nYOffset = 0; 
 
      // set the region transform to be used in region functions  
      nRet =lBmpRgn.SetRgnXForm(&XFormBtmp) ; 
      if(nRet !=SUCCESS) 
         return nRet; 
 
      // Specify the vertices of the polygon (a 5-pointed star) 
      pPolyPt[0].x = 0; 
      pPolyPt[0].y = 0; 
 
      pPolyPt[1].x = rClientArea.right / 3; 
      pPolyPt[1].y = rClientArea.bottom / 2; 
 
      pPolyPt[2].x = rClientArea.right / 3; 
      pPolyPt[2].y = 0; 
 
      pPolyPt[3].x = 0; 
      pPolyPt[3].y = rClientArea.bottom / 3; 
 
      pPolyPt[4].x = rClientArea.right / 2; 
      pPolyPt[4].y = rClientArea.bottom / 3; 
 
      // Create a polygonal region  
      nRet =lBmpRgn.SetRgnPolygon( pPolyPt, 5, L_POLY_ALTERNATE); 
      if(nRet !=SUCCESS) 
         return nRet; 
 
      // Save the first polygonal region  
      hRgn = lBmpRgn.GetRgnHandle(); 
 
      // Free the region 
      nRet =lBmpRgn.Free(); 
      if(nRet !=SUCCESS) 
         return nRet; 
 
      // Add the saved region to the new one 
      nRet =lBmpRgn.SetRgnHandle(hRgn); 
      if(nRet !=SUCCESS) 
         return nRet; 
 
      /* 
      ... 
      ... 
      ... 
      */ 
 
      // Delete the HRGN object 
      DeleteObject(hRgn); 
   } 
 
   return nRet; 
} 
Help Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.