L_HolesRemovalBitmapRgn

#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.

This function is available in the Document and Medical Imaging toolkits.

Parameter

Description

pBitmap

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

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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

LTIMGEFX

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 2000 / XP/Vista.

See Also

Functions:

L_IntensityDetectBitmap, L_SpatialFilterBitmap, L_BinaryFilterBitmap, L_MaxFilterBitmap, L_MinFilterBitmap, L_SetBitmapRgnMagicWand, L_SmoothBitmap, L_BorderRemoveBitmap, L_InvertedTextBitmap, L_DotRemoveBitmap, L_HolePunchRemoveBitmap, L_AutoBinarizeBitmap, L_DynamicBinaryBitmap, L_AutoBinaryBitmap

Topics:

Working with the Existing Bitmap Region

 

Raster Image Functions: Creating and Using a Region

 

Color Halftone and Halftone Images

Example

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

#if defined (LEADTOOLS_V16_OR_LATER)
 L_INT HolesRemovalBitmapRgnExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;
   
   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\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(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Result.BMP"), &LeadBitmap, FILE_BMP, 24, 0, NULL);
   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);  

   
 
   return SUCCESS;
}
#else
 L_INT HolesRemovalBitmapRgnExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;
   
   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\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);
   if(nRet !=SUCCESS)
      return nRet;

   /* Fill the region with balck color*/
   L_FillBitmap(&LeadBitmap, RGB(0,0,0));
   L_SaveBitmap(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Result.BMP"), &LeadBitmap, FILE_BMP, 24, 0, NULL);
   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);  

   
 
   return SUCCESS;
}
#endif // LEADTOOLS_V16_OR_LATER