Combining Images with Regions (Delphi 6.0)
1. |
Start Delphi 6. |
|
2. |
If you didn’t install LEAD Raster View Control, install it as follows: |
|
|
On the Component pull-down menu, use the Import ActiveX Control… and select the LEAD Raster View Control (14.5). Press install, and then compile and install the package dclusr.dpk. |
|
3. |
Add 2 of the LEAD Raster View control to your form. Size and position the controls, as you want them to appear at run time. |
|
4. |
If you didn’t import LEAD Raster IO before, import it as follows: |
|
|
On the Project pull-down menu, use the Import Type library… and select the LEAD Raster IO Object Library (14.5). Press Install, and then compile and install the package dclusr.dpk. |
|
5. |
If you didn’t import LEAD Raster Process before, import it as follows: |
|
|
On the Project pull-down menu, use the Import Type library… and select the LEAD Raster Process Object Library (14.5). Press install, and then compile and install the package dclusr.dpk. |
|
6. |
From the ActiveX controls tab, add 2 of the LEAD Raster IO controls and 1 LEAD Raster Process control to your form. |
|
7. |
Add 2 buttons to your form and name them as follows: |
|
|
Name |
Caption |
|
btnLoad |
Load Images |
|
btnCombine |
Combine |
8. |
Handle the btnLoad button's OnClick event, and code the btnLoadClick procedure as follows: |
procedure TForm1.btnLoadClick(Sender: TObject);
begin
LEADRasterIO1.Load ( LEADRasterView1.Raster, 'r:\images\image1.cmp', 0, 1, 1 ) ;
LEADRasterIO2.Load ( LEADRasterView2.Raster, 'r:\images\image2.cmp', 0, 1, 1 ) ;
end;
9. |
Handle the btnCombine button's OnClick event, and code the btnCombineClick procedure as follows: |
procedure TForm1.btnCombineClick(Sender: TObject);
var
nDstLeft : Integer;
nDstTop : Integer;
nSrcLeft : Integer;
nSrcTop : Integer;
nDstWidth : Integer;
nDstHeight : Integer;
rClientArea : TRect;
begin
Windows.GetClientRect ( LEADRasterView1.Handle, rClientArea );
LEADRasterView1.Raster.SetRgnRect( Trunc(rClientArea.right/8),
Trunc(rClientArea.bottom/8),
Trunc(rClientArea.right/2),
Trunc(rClientArea.bottom/2),
L_RGN_SET);
nDstLeft := Trunc(LEADRasterView1.Raster.BitmapWidth /8 );
nDstTop := Trunc(LEADRasterView1.Raster.BitmapHeight /8 );
nDstWidth := Trunc(LEADRasterView1.Raster.BitmapWidth );
nDstHeight:= Trunc(LEADRasterView1.Raster.BitmapHeight );
nSrcLeft := 0;
nSrcTop := 0;
LEADRasterProcess1.Combine( LEADRasterView1.Raster, nDstLeft, nDstTop, nDstWidth, nDstHeight, LEADRasterView2.Raster, nSrcLeft, nSrcTop, CB_OP_ADD + CB_DST_0);
end;
10. |
At the beginning of the Unit1 file, add "LTRASTERLib_TLB" to the uses section. |
11. |
Run your program to test it. |