#include "l_bitmap.h"

L_LTDIS_API L_INT L_GetBitmapRgnBounds(pBitmap, pXForm, pRect)

Gets the bounding rectangle of the bitmap region.



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


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.

L_RECT* pRect

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


Value Meaning
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.

Required DLLs and Libraries


Win32, x64, Linux.

See Also




For complete sample code, refer to the STATUS.C module of the DEMO
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.

L_INT GetBitmapRgnBoundsExample(L_HWND hWnd, BITMAPHANDLE *pBitmap) 
   L_INT nRet; 
   RGNXFORM XForm;         /* Structure for transforming display coordinates */ 
   HDC      hWindowDC;     /* Device context of the current window */ 
   RECT     rcClient;      /* Client area of the current window */ 
   RECT     rcRgn;         /* Rectangle that defines the region */ 
   RECT     rcBounds; 
   L_INT    x; 
   /* Get the device context of the current window */ 
   hWindowDC = GetDC (hWnd); 
   /* Get the client area of the current window */ 
   GetClientRect(hWnd, &rcClient); 
   /* Specify a rectangle to define the region */ 
   SetRect(&rcRgn, BITMAPWIDTH(pBitmap)*1/4, BITMAPHEIGHT(pBitmap)*1/4,  
                   BITMAPWIDTH(pBitmap)*3/4, BITMAPHEIGHT(pBitmap)*3/4); 
   /* Create an elliptical region */ 
   nRet = L_SetBitmapRgnEllipse(pBitmap, NULL, &rcRgn, L_RGN_SET); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Set RGNXFORM fields, assuming that the display rectangle is the same 
   as the client area of the current window */ 
   /* Get the bounding rectangle, relative to the bitmap */ 
   XForm.uViewPerspective = TOP_LEFT; 
   XForm.nXScalarNum      = rcClient.right; 
   XForm.nXScalarDen      = BITMAPWIDTH(pBitmap); 
   XForm.nYScalarNum      = rcClient.bottom; 
   XForm.nYScalarDen      = BITMAPHEIGHT(pBitmap); 
   XForm.nXOffset         = 0; 
   XForm.nYOffset         = 0; 
   L_GetBitmapRgnBounds(pBitmap, &XForm, &rcBounds); 
   /* Select drawing objects */ 
   SelectObject(hWindowDC, GetStockObject(WHITE_PEN)); 
   SelectObject(hWindowDC, GetStockObject(NULL_BRUSH)); 
   SetROP2(hWindowDC, R2_NOT); 
   /* Draw the region's bounding rectangle */ 
   Rectangle(hWindowDC, rcBounds.left, rcBounds.top, rcBounds.right, rcBounds.bottom); 
   RestoreDC(hWindowDC, -1); 
   /* now frame the bitmap's actual rgn */ 
   for(x=L_FRAME_MOVING0; x<L_FRAME_MOVING7; x++) 
      L_FrameBitmapRgn(hWindowDC, pBitmap, &XForm, x); 
   /* Free the region */ 
   return SUCCESS; 

Help Version 21.0.2021.4.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help