Loading and Displaying an Image (Visual Basic)
Take the following steps to start a project and to add some code that displays an image on the main form:
1. |
Start Visual Basic. |
|
2. |
Add the LEAD RasterView Control to your project. |
|
|
On the Project pull-down menu, use the Components option, and select the LEAD RasterView Control (14.5). |
|
3. |
Add the LEAD Raster Object Library and LEAD Raster Variant Object Library to your project. |
|
|
On the Project pull-down menu, use the References option, and select the LEAD Raster Object Library (14.5). |
|
|
On the Project pull-down menu, use the References option, and select the LEAD Raster Variant Object Library (14.5). |
|
4. |
Add the LEAD RasterIO Object Library to your project. |
|
|
On the Project pull-down menu, use the References option, and select the LEAD RasterIO Object Library (14.5). |
|
5. |
Select the LEAD RasterView control; then add the control to your main form. Size and position the control as you want it to appear at run time. |
|
6. |
Add a command button to your form and name it as follows: |
|
|
Name |
Caption |
|
LoadLead |
Load Image |
7. |
Add the following initialization code to the main form's Load procedure. In online help, you can use the Edit pull-down menu to copy the block of code. |
Private Sub Form_Load()
'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 = 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
End Sub
8. |
Code the LoadLead button's click procedure as follows: |
Private Sub LoadLead_Click()
Dim RasterIO As New LEADRasterIO
RasterIO.Load LEADRasterView1.Raster, "v:\images\arcade.bmp", 0, 0, 1
End Sub
9. |
Run your program to test it. |
10. |
Save the project be used as a starting point for other tasks in this tutorial. |