Loading and Displaying an Image (C++ Builder 6.0)

Take the following steps to start a project and to add some code that displays an image on the main form:

1.

Start C++ Builder 6.0.

2.

If you didn’t install LEAD Raster View Control, install it.

 

On the Component pull-down menu, use the Import ActiveX Control… and select the LEAD Raster View Control (14.5). Press Install.

3.

Select LEAD Raster View control and add it to your main form. Size and position the control, as you want it to appear at run time.

4.

On the Project pull-down menu, use the Import Type library… and install the LEAD Raster IO object library (14.5). Then press OK.

5.

Select LEAD Raster IO, from the ActiveX tab and add it to your form.

6.

Add a button to your form and name it as follows:

 

Name

Caption

 

btnLoadImage

Load Image

7.

Code the Main form's Create procedure as follows. In online help, you can use the Edit pull-down menu to copy the block of code.

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   //Set defaults for displaying the image. 
   //These are all persistent properties that can be set in the properties box. 
   LEADRasterView1->Appearance = RASTERVIEW_APPEARANCE_FLAT; 
   LEADRasterView1->BorderStyle = 1; 
   LEADRasterView1->BackColor = ( TColor ) RGB(255, 255, 125); 
   LEADRasterView1->PaintDither = PAINTDITHER_DIFFUSION; 
   LEADRasterView1->PaintPalette = PAINTPALETTE_AUTO; 
   LEADRasterView1->AutoRepaint = true; 
   LEADRasterView1->AutoSize = false; 
   LEADRasterView1->AutoSetRects = true; 
   LEADRasterView1->PaintSizeMode = PAINTSIZEMODE_FIT; 
   LEADRasterView1->EnableFireMouse2Event= true;
}

8.

Code the btnLoadImage button's click procedure as follows:

void __fastcall TForm1::btnLoadImageClick(TObject *Sender) 
{
   LEADRasterIO1->Load ( LEADRasterView1->Raster, AnsiToOLESTR("c:\\Image1.cmp"), 0, 0, 1 ) ; 
}

9.

At the beginning of the Unit1.cpp file, include this file:

   #include "LTRASTERLib_TLB.h"

10.

Run your program to test it.

11.

Save the project to be used as a starting point for other tasks in this tutorial.