#include "l_bitmap.h"
L_LTDIS_APIL_INTL_SetBitmapRgnHandle(pBitmap, pXForm, hRgn, uCombineMode)
Creates or updates the bitmap region by adding a region that is specified by a Windows region handle.
Pointer to the bitmap handle referencing the bitmap where the region is to be created or updated.
Pointer to anRGNXFORMstructure that LEADTOOLS uses to translate between display coordinates and bitmap coordinates.
You should create this structure when the Windows region is created. Otherwise the device context values may not be available when you are ready to add the Windows region to the bitmap region.
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.
Handle to the Windows region.
The action to take regarding the existing bitmap region, if one is defined. For descriptions of the possible values, refer toCreating a Bitmap Region.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer toReturn Codes. |
Before calling this function, you must declare anRGNXFORMstructure 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 theRGNXFORMstructure description. For a description of common usage, refer toTranslating Coordinates for a Bitmap Region.
The device coordinates are the ones that were in effect at the time the Windows region was created.
If you want to assign a region from one bitmap to another, you must use theL_GetBitmapRgnHandlefunction to get region from the first bitmap; then use the L_SetBitmapRgnHandle function to assign the region to the second bitmap.
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 toCreating a Bitmap Region.
Required DLLs and Libraries
Win32, x64, Linux.
For complete sample code, refer to the DRAW
example.
This example creates and saves one elliptical region. It then creates a second
elliptical region and adds the saved region to it. Finally, it lightens the part of
the bitmap that is in the resulting region.
L_INT SetBitmapRgnHandleExample(L_HWND hWnd,pBITMAPHANDLE pBitmap)
{
L_INT nRet;
RGNXFORM XFormToBitmap; /* Structurefortransforming display coordinates */
RGNXFORM XFormFromBitmap; /* Structurefortransforming bitmap coordinates */
HDC hWindowDC; /* Device context of the current window */
RECT rClientArea; /* Client area of the current window */
RECT rRgnRect; /* Rectangle that defines the region */
HRGN SavedRegion; /* Windows region handle used to save a 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 */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), pBitmap,sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet != SUCCESS)
returnnRet;
/* Set XFormToBitmap fields, assuming that the display rectangle is the same
as the client area of the current window */
XFormToBitmap.uViewPerspective = TOP_LEFT;
XFormToBitmap.nXScalarNum = BITMAPWIDTH(pBitmap);
XFormToBitmap.nXScalarDen = rClientArea.right;
XFormToBitmap.nYScalarNum = BITMAPHEIGHT(pBitmap);
XFormToBitmap.nYScalarDen = rClientArea.bottom;
XFormToBitmap.nXOffset = 0;
XFormToBitmap.nYOffset = 0;
/* 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 = rClientArea.right;
XFormFromBitmap.nXScalarDen = BITMAPWIDTH(pBitmap);
XFormFromBitmap.nYScalarNum = rClientArea.bottom;
XFormFromBitmap.nYScalarDen = BITMAPHEIGHT(pBitmap);
XFormFromBitmap.nXOffset = 0;
XFormFromBitmap.nYOffset = 0;
/* Specify a rectangle to define the first elliptical region */
SetRect(&rRgnRect, 0, rClientArea.bottom/8,
rClientArea.right/4, rClientArea.bottom/2);
/* Create the first elliptical region */
nRet = L_SetBitmapRgnEllipse(pBitmap, &XFormToBitmap, &rRgnRect, L_RGN_SET);
if(nRet != SUCCESS)
returnnRet;
/* Save the first elliptical region */
nRet = L_GetBitmapRgnHandle(pBitmap, &XFormFromBitmap, &SavedRegion);
if(nRet != SUCCESS)
returnnRet;
/* Free the region */
L_FreeBitmapRgn(pBitmap);
/* Specify a rectangle to define the second elliptical region */
SetRect(&rRgnRect, rClientArea.right/4, rClientArea.bottom/8,
rClientArea.right/2, rClientArea.bottom/2);
/* Create the second elliptical region */
nRet = L_SetBitmapRgnEllipse(pBitmap, &XFormToBitmap, &rRgnRect, L_RGN_SET);
if(nRet != SUCCESS)
returnnRet;
/* Add the saved region to thenewone, resultinginside-by-side elliptical shapes */
nRet = L_SetBitmapRgnHandle(pBitmap, &XFormToBitmap, SavedRegion, L_RGN_OR);
if(nRet != SUCCESS)
returnnRet;
/* Lighten the region so that we will see it */
nRet = L_ChangeBitmapIntensity(pBitmap,500, 0);
if(nRet != SUCCESS)
returnnRet;
/* Delete the HRGN object */
DeleteObject(SavedRegion);
returnSUCCESS;
}
帮助收藏
Raster.NET|C API|C++ Class Library|HTML5 JavaScript
文档.NET|C API|C++ Class Library|HTML5 JavaScript
医疗.NET|C API|C++ Class Library|HTML5 JavaScript
医疗Web Viewer.NET
188宝金博怎么下载
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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.