L_SetBitmapRgnRoundRect

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_SetBitmapRgnRoundRect(pBitmap, pXForm, pRect, nWidthEllipse, nHeightEllipse, uCombineMode)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

pRGNXFORM pXForm;

/* pointer to a coordinate-translation structure */

RECT L_FAR * pRect;

/* pointer to the bounding rectangle of the region */

L_INT nWidthEllipse;

/* width of the ellipse used for rounded corners */

L_INT nHeightEllipse;

/* height of the ellipse used for rounded corners */

L_UINT uCombineMode;

/* action to take regarding the existing region */

Creates or updates the bitmap region by adding a rounded rectangular 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.

pRect

Pointer to the windows RECT structure that specifies the bounding rectangle of the region. You specify the structure using device context coordinates, and LEADTOOLS translates the coordinates using the values specified in the pXForm parameter.

nWidthEllipse

The width of the ellipse that describes the arc of the rounded corners. You specify the measurement in device context pixels, and LEADTOOLS translates the coordinates using the values specified in the pXForm parameter.

nHeightEllipse

The height of the ellipse that describes the arc of the rounded corners. You specify the measurement in device context pixels, and LEADTOOLS translates the coordinates using the values specified in the pXForm parameter.

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.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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.

The following illustration shows how you describe the rounded corners by specifying the width and height of an ellipse:

image\rndrect.gif

Required DLLs and Libraries

LTDIS

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_SetBitmapRgnColor, L_SetBitmapRgnEllipse, L_SetBitmapRgnPolygon, L_SetBitmapRgnRect

Topics:

Raster Image Functions: Creating and Using a Region

 

Raster Image Functions: Region Processing

 

Defining and Using a Bitmap Region

 

Saving a Region

Example

For complete sample code, refer to the CHILD.C module of the DEMO example.

/* This example creates a rounded rectangular region and lightens 
the part of the bitmap that is in the region */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the image */
void TestFunction(HWND hWnd)
{
   RGNXFORM XForm; /* Structure for transforming display coordinates */
   HDC hWindowDC;  /* Device context of the current window */
   RECT rClientArea; /* Client area of the current window */
   RECT rRgnRect; /* Rectangle that defines the region */
   /* Get the device context of the current window */
   hWindowDC = GetDC (hWnd);
   /* Get the client area of the current window */
   GetClientRect(hWnd,&rClientArea);
   /* Load a bitmap */
   L_LoadBitmap (TEXT("IMAGE3.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   /* 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(&LeadBitmap);
   XForm.nXScalarDen = rClientArea.right;
   XForm.nYScalarNum = BITMAPHEIGHT(&LeadBitmap);
   XForm.nYScalarDen = rClientArea.bottom;
   XForm.nXOffset = 0;
   XForm.nYOffset = 0;
   /* Specify a rectangle to define the region */
   SetRect(&rRgnRect, rClientArea.right/8, rClientArea.bottom/8, 
      rClientArea.right/2, rClientArea.bottom/2);
   /* Create a rounded rectangular region */
   L_SetBitmapRgnRoundRect(&LeadBitmap, &XForm, &rRgnRect, 
   rClientArea.right/16, /* Width of the ellipse that defines the corners */
   rClientArea.right/16, /* Height of the ellipse that defines the corners */
   L_RGN_SET);
   /* Lighten the region so that we will see it */
   L_ChangeBitmapIntensity(&LeadBitmap,500);
   /* Free the region */
   L_FreeBitmapRgn(&LeadBitmap);
   return;
}