Removes all the holes in a region.
#include "l_bitmap.h"
L_LTIMGEFX_API L_INT L_HolesRemovalBitmapRgn(pBitmap, uFlags)
Pointer to the bitmap handle referencing the bitmap to be changed.
Reserved for future use. Must be 0.
Value | Meaning |
---|---|
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.
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
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 black 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;
}
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