#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_HolesRemovalBitmapRgn(pBitmap, uFlags)

Removes all the holes in a region.



Pointer to the bitmap handle referencing the bitmap to be changed.

L_UINT32 uFlags

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.

Required DLLs and Libraries


Win32, x64, Linux.

See Also




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 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  
   return SUCCESS; 

Help Version 21.0.2021.4.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help