#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.
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.
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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document