#include "l_bitmap.h"
L_LTDIS_API L_INT L_SetBitmapRgnPolygon(pBitmap, pXForm, pPoints, uPoints, uFillMode, uCombineMode)
pBITMAPHANDLE pBitmap; |
pointer to the bitmap handle |
pRGNXFORM pXForm; |
pointer to a coordinate-translation structure |
L_POINT* pPoints; |
pointer to an array of POINT structures |
L_UINT uPoints; |
number of points in the array |
L_UINT uFillMode; |
indicates how to handle complex crossing lines |
L_UINT uCombineMode; |
action to take regarding the existing region |
Creates or updates the bitmap region by adding a polygonal region.
Parameter | Description | |
pBitmap | Pointer to the bitmap handle referencing the bitmap where the region is to be created or updated. | |
pXForm | Pointer to an RGNXFORM structure that LEADTOOLS uses to translate between display coordinates and bitmap coordinates. | |
If you specify NULL in this parameter, the scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the bitmap's view perspective. | ||
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. | |
uPoints | The number of points in the array specified by the pPoints parameter. | |
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. | |
uCombineMode | The action to take regarding the existing bitmap region, if one is defined. For descriptions of the possible values, refer to Creating a Bitmap Region. |
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Before calling this function, you must declare an RGNXFORM structure and set its values, which LEADTOOLS uses to translate between device context coordinates and bitmap coordinates. For details about how the structure works refer to the RGNXFORM structure description. For a description of common usage, refer to Translating Coordinates for a Bitmap Region.
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
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64, Linux.
Functions: |
L_SetBitmapRgnColor, L_SetBitmapRgnEllipse, L_SetBitmapRgnRect, L_SetBitmapRgnRoundRect |
Topics: |
|
|
|
|
|
|
For complete sample code, refer to the CHILD.C module of the DEMO example. This example creates a polygonal region and, using the alternate fill mode, lightens the part of the bitmap that is in the region.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT SetBitmapRgnPolygonExample(L_HWND hWnd, pBITMAPHANDLE pBitmap)
{
L_INT nRet;
RGNXFORM XForm; /* Structure for transforming display coordinates */
HDC hWindowDC; /* Device context of the current window */
RECT rClientArea; /* Client area of the current window */
POINT PolyPt[5]; /* Array of points that defines the polygon */
POINT* pPolyPt = PolyPt; /* Pointer to the array of points */
/* Get the device context of the current window */
hWindowDC = GetDC (hWnd);
/* Get the client area of the current window */
GetClientRect(hWnd,&rClientArea);
/* 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;
/* Load a bitmap */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), pBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet != SUCCESS)
return nRet;
/* Set RGNXFORM fields, assuming that the display rectangle is the same
as the client area of the current window */
XForm.uViewPerspective = TOP_LEFT;
XForm.nXScalarNum = BITMAPWIDTH(pBitmap);
XForm.nXScalarDen = rClientArea.right;
XForm.nYScalarNum = BITMAPHEIGHT(pBitmap);
XForm.nYScalarDen = rClientArea.bottom;
XForm.nXOffset = 0;
XForm.nYOffset = 0;
/* Create a polygonal region */
nRet = L_SetBitmapRgnPolygon(pBitmap, &XForm, pPolyPt, 5, L_POLY_ALTERNATE, L_RGN_SET);
if(nRet != SUCCESS)
return nRet;
/* Lighten the region so that we will see it */
nRet = L_ChangeBitmapIntensity(pBitmap,500, 0);
if(nRet != SUCCESS)
return nRet;
/* Free the region */
L_FreeBitmapRgn(pBitmap);
return SUCCESS;
}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET