#include "l_bitmap.h"
L_LTIMGEFX_API L_INT L_HolesRemovalBitmapRgn(pBitmap, uFlags)
pBITMAPHANDLE pBitmap; |
pointer to the bitmap handle |
L_UINT32 uFlags; |
flags |
Removes all the holes in a region.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle referencing the bitmap to be changed. |
uFlags |
Reserved for future use. Must be 0. |
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
This function is designed to work on bitmaps that have a region. It removes the holes from the bitmaps region. If this function is used with a bitmap that does not have a region, the "Invalid Parameter" error is returned.
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.
This function supports 32-bit grayscale images.
Required DLLs and Libraries
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64, Linux.
This example loads a bitmap, defines a region on it after converting to 1bit black and white, and applies the holes removal filter to remove small white or black segments
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT HolesRemovalBitmapRgnExample(L_VOID)
{
L_INT nRet;
BITMAPHANDLE LeadBitmap;
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet !=SUCCESS)
return nRet;
/*convert to 1-bit black and white*/
nRet = L_ColorResBitmap(&LeadBitmap, &LeadBitmap, sizeof(BITMAPHANDLE), 1,CRF_FIXEDPALETTE,
NULL, NULL, 0, NULL, NULL);
if(nRet !=SUCCESS)
return nRet;
/*Set the region around the black or white region according to (0,0) color*/
nRet = L_SetBitmapRgnMagicWand(&LeadBitmap,0, 0, RGB(0,0,0), RGB(25,25,25), L_RGN_SET);
if(nRet !=SUCCESS)
return nRet;
/*Remove holes around the black or white regions*/
nRet = L_HolesRemovalBitmapRgn (&LeadBitmap, 0);
if(nRet !=SUCCESS)
return nRet;
/* Fill the region with balck color*/
L_FillBitmap(&LeadBitmap, RGB(0,0,0));
L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL);
//free bitmap
if(LeadBitmap.Flags.Allocated)
L_FreeBitmap(&LeadBitmap);
return SUCCESS;
}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET