L_GetBitmapRgnBounds

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_GetBitmapRgnBounds(pBitmap, pXForm, pRect)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

pRGNXFORM pXForm;

/* pointer to a coordinate translation structure */

RECT L_FAR * pRect;

/* address of the RECT structure to be updated */

Gets the bounding rectangle of the bitmap region.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap that has the region.

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

Address of the RECT variable for the bounding rectangle that this function is to update.

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.

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_OffsetBitmapRgn

Topics:

Raster Image Functions: Creating and Using a Region

 

Raster Image Functions: Region Processing

 

Defining and Using a Bitmap Region

Example

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

/****************************************************************************************
This example, which uses a button click to display the bounding rectangle of the bitmap region,
includes sections from a program’s message-processing function. The sample code uses the
following global variables: */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */
L_INT DisplayWidth, DisplayHeight; /* Dimensions of the displayed image */
/* TestFunction(), used in this example, can be copied from the example for L_SetBitmapRgnEllipse.
*****************************************************************************************/
L_INT32 EXT_FUNCTION MainWndProc (HWND hWnd, L_UINT Message, WPARAM wParam,
                                   LPARAM lParam)
{
            o
            o
            o
   int DisplayMode; /* ROP2 code used for drawing */
   HDC hdc; /* Device context used with the palette functions */
   RGNXFORM XFormFromBitmap; /* Structure for transforming bitmap coordinates */
   RECT rRgn; /* Bounding rectangle of the bitmap region */
   switch (Message)
   {
   case WM_CREATE:
      /* Load the bitmap and create the region */
      TestFunction(hWnd);
            o
            o
            o
   case WM_RBUTTONDOWN:
      /* Set XFormFromBitmap fields, assuming that the display rectangle is the same
      as the client area of the current window */
      XFormFromBitmap.uViewPerspective = TOP_LEFT;
      XFormFromBitmap.nXScalarNum = DisplayWidth;
      XFormFromBitmap.nXScalarDen = BITMAPWIDTH(&LeadBitmap);
      XFormFromBitmap.nYScalarNum = DisplayHeight;
      XFormFromBitmap.nYScalarDen = BITMAPHEIGHT(&LeadBitmap);
      XFormFromBitmap.nXOffset = 0;
      XFormFromBitmap.nYOffset = 0;
      /* Get the bounding rectangle, relative to the bitmap */
      L_GetBitmapRgnBounds(&LeadBitmap, &XFormFromBitmap, &rRgn);
      /* Get the current device context */
      hdc = GetDC(hWnd);
      /* Select drawing objects */
      SelectObject(hdc, GetStockObject(WHITE_PEN));
      SelectObject(hdc, GetStockObject(NULL_BRUSH));
      /* Save the current display mode */
      DisplayMode = GetROP2(hdc);
      /* Change the display mode to invert colors when we display the rectangle */
      SetROP2(hdc, R2_NOT);
      /* Draw the region's bounding rectangle */
      Rectangle(hdc, rRgn.left, rRgn.top, rRgn.right, rRgn.bottom);
      /* Restore the saved display mode */
      SetROP2(hdc, DisplayMode);
      return (0);
            o
            o
            o
            o