hDocCleanRgn example for Delphi
procedure TForm1.Button4Click(Sender: TObject);
var
nRet :Integer;
begin
{HolePunch Remove}
{This example updates a windows region with all 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 update 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 HolePunch Event is used to display information about each hole punch removed}
nRet := LEADImage1.HolePunchRemove (HOLEPUNCH_SINGLE_REGION Or HOLEPUNCH_USE_DPI Or HOLEPUNCH_USE_COUNT Or HOLEPUNCH_USE_LOCATION,
2, 4, 0, 0, 0, 0, HOLEPUNCH_LEFT);
if (nRet = SUCCESS) then
begin
LEADImage1.FreeRgn;
LEADImage1.SetRgnHandle (LEADImage1.hDocCleanRgn, 0, 0, L_RGN_SET);
LEADImage1.hDocCleanRgn := 0 ;{no longer need rgn}
LEADImage1.RgnFrameType := ftAnimated;
end;
end;
procedure TForm1.LEADImage1HolePunchRemove (Sender: TObject; hHoleRgn: L_HRGN;
nBoundingRectLeft, nBoundingRectTop, nBoundingRectWidth,
nBoundingRectHeight, iHoleIndex, iHoleTotalCount, iWhiteCount,
iBlackCount: Integer);
var
sOutput : String;
szTemp : array[0..255] of Char;
begin
sOutput := Format ('HolePunch at %d,%d,%d,%d HoleIndex= %d TotalCount= %d WhiteCount= %d BlackCount= %d',
[nBoundingRectLeft,
nBoundingRectTop,
nBoundingRectWidth,
nBoundingRectHeight,
iHoleIndex,
iHoleTotalCount,
iWhiteCount,
iBlackCount]);
OutputDebugString(StrPCopy(szTemp,sOutput));
end;