CombineExt example for Delphi

This example copies the Lead1 bitmap to Lead2, trims and filters the copied image, and combines the filtered image with the original Lead1 bitmap image. Trimming Lead2 lets you see the difference between filtered and nonfiltered regions.

 

Var
   TrimLeft: Integer;
   TrimTop, TrimWidth, TrimHeight: Integer;
   DstLeft, DstTop, DstWidth, DstHeight: Integer;
   SrcLeft, SrcTop: Integer;
begin
   LEADImage2.Bitmap := LEADImage1.Bitmap;
   TrimLeft := Trunc(LEADImage2.BitmapWidth * 0.2);
   TrimTop := Trunc(LEADImage2.BitmapHeight * 0.2);
   TrimWidth := Trunc(LEADImage2.BitmapWidth * 0.6);
   TrimHeight := Trunc(LEADImage2.BitmapHeight * 0.6);
   LEADImage2.Trim (TrimLeft, TrimTop, TrimWidth, TrimHeight);
   LEADImage2.SpatialFilter (FLT_LINESEG_HORZ);
   DstLeft := TrimLeft;
   DstTop := TrimTop;
   DstWidth := TrimWidth;
   DstHeight := TrimHeight;
   SrcLeft := 0;
   SrcTop := 0;
   LEADImage1.CombineExt (DstLeft, DstTop, DstWidth, DstHeight, LEADImage2.Bitmap, SrcLeft, SrcTop, CB_OP_ADD);
   LEADImage1.ForceRepaint();
end;