LBitmap::HolePunchRemove

#include "ltwrappr.h"

virtual L_INT LBitmap::HolePunchRemove(pHolePunchRemove, uFlags = 0)

pHOLEPUNCH pHolePunchRemove;

/* pointer to a structure */

L_UINT32 uFlags;

/* flags */

Finds and removes hole punches.

Parameter

Description

pHolePunchRemove

Pointer to the HOLEPUNCH structure that LEADTOOLS uses to remove hole punches.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

For example, this image must have the vertical line removed. Use LBitmap::LineRemove to remove any horizontal or vertical lines from the image.  Use other Document Cleanup functions to remove other imaging artifacts such as dots, blobs, borders, inverted text, bumps and nicks.  This will have the added benefit of making your image smaller when compressed.

Once cleaned,  L_HolePunchRemoveBitmap will be able to identify and remove the hole punch mark.

 

Required DLLs and Libraries

LTIMGCOR

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

Win32, x64.

See Also

Functions:

LBitmap::HolePunchRemoveCallback, LBitmap::Smooth, LBitmap::LineRemove, LBitmap::BorderRemove, LBitmap::DotRemove, LBitmap::InvertedText, LBitmap::AutoBinarize, LBitmap::DynamicBinary, LBitmap::AutoBinary, Class Members

Topics:

Cleaning Up 1-Bit Images

Example

//This example updates a Windows region with removed hole punches

//For the example, a Windows region is updated and then converted to a LEAD region

//but in practice it would easier and faster to just return a LEAD region

//The HOLEPUNCH_USE_DPI flag instructs the API to determine the size of the hole punches

// based on the image DPI

//The image is modified

//The derived class LMyBitmap is used to override the HolePunchRemoveCallBack function

//The callback member function is used to display information about each hole punch removed

//The callback member function does NOT receive a Windows region

class LHolePunchRemoveBitmap : public LBitmap
{
public:
   LHolePunchRemoveBitmap();
   ~LHolePunchRemoveBitmap();
   virtual L_INT HolePunchRemoveCallBack(HRGN          hRgn, 
                                         PRECT         pBoundingRect, 
                                         L_INT32       iHoleIndex,  
                                         L_INT32       iHoleTotalCount, 
                                         L_INT32       iWhiteCount, 
                                         L_INT32       iBlackCount
                                         );
};
LHolePunchRemoveBitmap::LHolePunchRemoveBitmap()
{
}
LHolePunchRemoveBitmap::~LHolePunchRemoveBitmap()
{
}
L_INT LBitmap__HolePunchRemoveExample(LBitmapWindow *pBitmapWindow)
{
   L_INT32           nRet;
   HOLEPUNCH         hr;
   hr.uStructSize          = sizeof(HOLEPUNCH);
   hr.iLocation      = HOLEPUNCH_LEFT;
   hr.iMinHoleCount  = 2;
   hr.iMaxHoleCount  = 4;
   hr.pBitmapRegion  = NULL;
   hr.uFlags         = HOLEPUNCH_SINGLE_REGION | HOLEPUNCH_USE_DPI | HOLEPUNCH_USE_COUNT | HOLEPUNCH_USE_LOCATION;
   nRet = pBitmapWindow->HolePunchRemove(&hr);
   if (nRet == SUCCESS)
   {
      //Delete the existing region
      LBitmapRgn Region(pBitmapWindow);
      if(Region.BitmapHasRgn())
      {
         Region.Free();
      }
      Region.SetRgnCombineMode(L_RGN_SET) ;
      Region.SetRgnHandle(hr.hRgn);
      DeleteObject(hr.hRgn);
   }
   return SUCCESS;
}
L_INT LHolePunchRemoveBitmap::HolePunchRemoveCallBack(
   HRGN          hRgn, 
   PRECT         pBoundingRect, 
   L_INT32       iHoleIndex,  
   L_INT32       iHoleTotalCount, 
   L_INT32       iWhiteCount, 
   L_INT32       iBlackCount
   )
{
   UNREFERENCED_PARAMETER(hRgn);
   CString strMsg;
   strMsg.Format (
      TEXT("Bounds[%d,%d][%d,%d]\tHole[%d] of [%d]\tWhiteCount[%d]\tBlackCount[%d]\n"),
      pBoundingRect->left,
      pBoundingRect->top,
      pBoundingRect->right,
      pBoundingRect->bottom,
      iHoleIndex,
      iHoleTotalCount,
      iWhiteCount,
      iBlackCount
      );
   OutputDebugString(strMsg);
   return SUCCESS_REMOVE; 
}