L_HolePunchRemoveBitmap

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_HolePunchRemoveBitmap(pBitmap, pHolePunch, pfnCallback, pUserData, uFlags)

pBITMAPHANDLE pBitmap;

pointer to the bitmap

pHOLEPUNCH pHolePunch;

pointer to a structure

HOLEPUNCHREMOVECALLBACK pfnCallback;

optional callback function

L_VOID *pUserData;

pointer to more parameters for the callback

L_UINT32 uFlags;

flags

Finds and removes hole punches.

Parameter Description
pBitmap Pointer to the bitmap handle referencing the bitmap from which to remove hole punches.
pHolePunch Pointer to the HOLEPUNCH structure that LEADTOOLS uses to remove hole punches.
pfnCallback Optional callback function for additional processing.
  -  If you do not provide a callback function, use NULL as the value of this parameter.
  -  If you do provide a callback function, use the function pointer as the value of this parameter.
  The callback function must adhere to the function prototype described in HOLEPUNCHREMOVECALLBACK Function.
pUserData Void pointer that you can use to pass one or more additional parameters that the callback function needs.
  To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID  *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.
  If the additional parameters are not needed, you can pass NULL in this parameter.
uFlags A flag that determine the method used to detect the Hole punch, possible values are:
  Flags Meaning
  HOLEPUNCH_NORMAL_DETECTION [0x00000000] Use Normal Hole Punch Detection
  HOLEPUNCH_ADVANCED_DETECTION [0x00010000] Use Advanced Hole Punch Detection to return more accurate results

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. You can use L_LineRemoveBitmap 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, Linux.

See Also

Functions:

HOLEPUNCHREMOVECALLBACK, L_SmoothBitmap, L_LineRemoveBitmap, L_AutoLineRemove, L_BorderRemoveBitmap, L_DotRemoveBitmap, L_InvertedTextBitmap, L_HolesRemovalBitmapRgn, L_AutoBinarizeBitmap, L_DynamicBinaryBitmap, L_AutoBinaryBitmap, L_InvertedPageBitmap

Topics:

Cleaning Up 1-Bit Images

Example

This example returns a windows region corresponding to hole punches. For the example, a windows region is returned and 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. A callback is used to display information about each hole punch removed. The callback does NOT return a region.

L_INT EXT_CALLBACK HolePunchRemoveCB(HRGN hRgn, PRECT pBoundingRect, L_INT32 iHoleIndex, L_INT32 iHoleTotalCount, L_INT32 iWhiteCount, L_INT32 iBlackCount, L_VOID* pUserData) 
{ 
   UNREFERENCED_PARAMETER(pUserData); 
   L_TCHAR szMsg[200]; 
   RECT rcRect; 
   GetRgnBox(hRgn, &rcRect); 
   wsprintf( 
   szMsg, 
   TEXT("Region Bounds: left=%d, right=%d, top=%d, bottom=%d \n"), 
   rcRect.left, rcRect.right, rcRect.top, rcRect.bottom); 
   OutputDebugString(szMsg); 
   DeleteObject(hRgn); 
   wsprintf(szMsg, 
   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(szMsg); 
   return SUCCESS_REMOVE; 
} 
L_INT HolePunchRemoveBitmapExample(pBITMAPHANDLE pBitmap) 
{ 
   L_INT32           nRet; 
   HOLEPUNCH         hr; 
   BITMAPHANDLE      BitmapRegion; 
   memset(&BitmapRegion, 0, sizeof(BITMAPHANDLE)); 
   hr.uStructSize = sizeof(HOLEPUNCH); 
   hr.iLocation      = HOLEPUNCH_LEFT; 
   hr.iMinHoleCount  = 2; 
   hr.iMaxHoleCount  = 4; 
   hr.pBitmapRegion = &BitmapRegion; 
   hr.uBitmapStructSize = sizeof(BITMAPHANDLE); 
   hr.uFlags  = HOLEPUNCH_SINGLE_REGION | HOLEPUNCH_USE_DPI | HOLEPUNCH_USE_COUNT | HOLEPUNCH_USE_LOCATION | HOLEPUNCH_CALLBACK_REGION; 
   nRet = L_HolePunchRemoveBitmap( 
   pBitmap, 
   &hr, 
   HolePunchRemoveCB, 
   NULL, 0); 
   if (nRet == SUCCESS) 
   { 
      RECT rectRgn; 
      GetRgnBox(hr.hRgn, &rectRgn); 
      if (!IsRectEmpty(&rectRgn)) 
      { 
         L_SetBitmapRgnHandle(pBitmap, NULL, hr.hRgn, L_RGN_SET); 
         DeleteObject(hr.hRgn); 
         hr.hRgn = NULL; 
      } 
   } 
   else 
   { 
      return nRet; 
   } 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help