Loading and Displaying an Image (C++ Builder)
Take the following steps to start a project and to add some code that positions, scales, and displays an image on the main form:
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 this tutorial. |
4. |
Select the LEAD Main control on the VCL toolbar. Size and position the control as you want it to appear at run time, and change the name of the control to Lead1. |
5. |
Add a command button to your form and name it as follows: |
Name |
Caption |
LoadLead |
Load Image |
6. |
Code the main form's FormShow procedure as follows. In online help, you can copy the block of code and paste it into your application. |
void __fastcall TForm1::FormShow(TObject *Sender)
{
// Set defaults for displaying the image.
// These are all persistent properties that can be set in the properties box.
Lead1->BorderStyle = bsSingle;
Lead1->BackColor = RGB(255, 255, 125);
Lead1->PaintDither = pdDiffusion;
Lead1->PaintPalette = ppAuto;
Lead1->AutoRepaint = True;
Lead1->AutoSize = False;
Lead1->AutoSetRects = True;
Lead1->PaintSizeMode = smFit;
}
7. |
Code the LoadLead button's click procedure as follows: |
void __fastcall TForm1::LoadLeadClick(TObject *Sender)
{
Lead1->Load("c:\\lead\\images\\image1.cmp", 0, 0, 1);
}
8. |
On the Project menu, select Build Project. |
9. |
Run your program to test it. |
10. |
Save the project to use as a starting point for other tasks in this tutorial. |