Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.21
COM Interoperability: Loading and Displaying an Image

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 6.
2.Add the LEAD RasterImageViewer Control to your project.
On the Project pull-down menu, use the Components option, and select the LTDWinFormsInterop..
3.Add the RasterCodecs to your project.
On the Project pull-down menu, use the References option, and select the LTDCodecsInterop.
4.Select the RasterImageViewer control; then add the control to your main form. Size and position the control as you want it to appear at run time.
5.Add a command button to your form and name it as follows:
NameCaption
LoadLeadLoad Image
6.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.

' Set defaults for displaying the image.
' These are all persistent properties that can be set in the properties box.
Private Sub Form_Load()
  'Set defaults for displaying the image.
  'These are all persistent properties that can be set in the properties box.
  RasterImageViewer1.BorderStyle = BorderStyle_Fixed3D
  RasterImageViewer1.AutoScroll = True
End Sub
7.Code the LoadLead button's click procedure as follows:

Private Sub LoadLead_Click()
Dim Codecs As New RasterCodecs
  Codecs.Startup
  Set RasterImageViewer1.Image = Codecs.Load_12("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\IMAGE1.CMP")
  Codecs.Shutdown 
End Sub
8.Run your program to test it.
9.Save the project be used as a starting point for other tasks in this tutorial.