hDocCleanRgn example for Delphi
var
RasterProc: LEADRasterProcess;
//Create the RasterProcess object and UnlockSupport
procedure TForm1.Button1Click (Sender: TObject);
begin
//.....
RasterProc:= CoLEADRasterProcess.Create ();
LEADRasterView1.Raster.UnlockSupport (L_SUPPORT_DOCUMENT, 'TestKey');
LEADEventSink1.Connect (RasterProc, _LEADRasterProcessEvents);
//.....
end;
procedure TForm1.Button2Click(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}
RasterProc.EnableDocCleanEvents:= True;
nRet:= RasterProc.HolePunchRemove (LEADRasterView1.Raster,
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 = 0) Then
begin
LEADRasterView1.Raster.FreeRgn ( ) ;
LEADRasterView1.Raster.SetRgnHandle ( RasterProc.hDocCleanRgn, 0, 0, L_RGN_SET); RasterProc.hDocCleanRgn:= 0; //no longer need rgn
LEADRasterView1.RgnFrameType:= RGNFRAME_COLOR;
end;
end;
procedure TForm1.LEADEventSink1Invoke(Sender: TObject; DispID: Integer;
const IID: TGUID; LocaleID: Integer; Flags: Word; Params: tagDISPPARAMS;
varResult, ExcepInfo, ArgErr: Pointer);
var
fBoundingRectLeft: single;
fBoundingRectTop: single;
fBoundingRectWidth: single;
fBoundingRectHeight: single;
iHoleIndex: integer;
iHoleTotalCount: Integer;
iWhiteCount: Integer;
iBlackCount: Integer;
sOutput : String;
szTemp : array[0..255] of Char;
begin
case (DispID) of
LEADRASTERPROCESSEVENTS_HOLEPUNCHREMOVE:
begin
fBoundingRectLeft:= OleVariant(Params.rgvarg[7]);
fBoundingRectTop:= OleVariant(Params.rgvarg[6]);
fBoundingRectWidth:= OleVariant(Params.rgvarg[5]);
fBoundingRectHeight:= OleVariant(Params.rgvarg[4]);
iHoleIndex:= OleVariant(Params.rgvarg[3]);
iHoleTotalCount:= OleVariant(Params.rgvarg[2]);
iWhiteCount:= OleVariant(Params.rgvarg[1]);
iBlackCount:= OleVariant(Params.rgvarg[0]);
sOutput := Format ('HolePunch at %f,%f,%f,%f HoleIndex= %d TotalCount= %d WhiteCount= %d BlackCount= %d',
[fBoundingRectLeft,
fBoundingRectTop,
fBoundingRectWidth,
fBoundingRectHeight,
iHoleIndex,
iHoleTotalCount,
iWhiteCount,
iBlackCount]);
OutputDebugString(StrPCopy(szTemp,sOutput));
end;
end;
end;