Combining Images with Regions (C++Builder)
1. |
Start C++ Builder. |
|
2. |
In the File menu, choose New Application. |
|
3. |
On the Builder toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial. |
|
4. |
Add 2 of the LEAD Main VCL controls to your form. Size and position the controls, as you want them to appear at run time. |
|
5. |
Add a button to your form and name it as follows: |
|
|
Name |
Caption |
|
btnCombine |
Combine |
6. |
Handle the Form1 OnCreate event, and code FormCreate as follows: |
void __fastcall TForm1::FormCreate(TObject *Sender)
{
LEADImage1->Load("r:\\images\\image1.cmp", 0, 1, 1);
LEADImage2->Load ("r:\\images\\image2.cmp", 0, 1, 1);
}
7. |
Handle the btnCombine button's OnClick event, and code the btnCombineClick procedure as follows: |
void __fastcall TForm1::btnCombineClick(TObject *Sender)
{
int nDstLeft;
int nDstTop;
int nSrcLeft;
int nSrcTop;
int nDstWidth;
int nDstHeight;
TRect rClientArea;
::GetClientRect ( LEADImage1->Handle, &rClientArea );
LEADImage1->SetRgnRect ( (int)(rClientArea.right/8), (int)(rClientArea.bottom/8), (int)(rClientArea.right/2), (int)(rClientArea.bottom/2), L_RGN_SET);
nDstLeft = (int)(LEADImage1->BitmapWidth /8 );
nDstTop = (int)(LEADImage1->BitmapHeight /8 );
nDstWidth = (int)(LEADImage1->BitmapWidth );
nDstHeight= (int)(LEADImage1->BitmapHeight );
nSrcLeft = 0;
nSrcTop = 0;
LEADImage1->Combine( nDstLeft, nDstTop, nDstWidth, nDstHeight, LEADImage2->Bitmap, nSrcLeft, nSrcTop, CB_OP_ADD + CB_DST_0);
}
8. |
Run your program to test it. |