L_GetBitmapRgnBounds

#include "l_bitmap.h"

L_LTDIS_API L_INT L_GetBitmapRgnBounds(pBitmap, pXForm, pRect)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

pRGNXFORM pXForm;

pointer to a coordinate translation structure

L_RECT* 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

Win32, x64, Linux.

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.

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); 
   SaveDC(hWindowDC); 
   /* 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); 
      Sleep(500); 
   } 
   /* Free the region */ 
   L_FreeBitmapRgn(pBitmap); 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help