Take the following steps to start a project and to add some code that loads and displays an image:
In the "Solution Explorer" window, right-click on the "References" folder, and select "Add Reference…" from the context menu. In the "Add Reference" dialog box, select the ".NET" tab and browse to Leadtools For .NET "<LEADTOOLS_INSTALLDIR>\Bin\DotNet4\Win32 " folder and select the following DLLs:
Click the Select button and then press the OK button to add the above DLLs to the application.
Make sure Form1 is in design view. Go to the toolbox (View->Toolbox) and Drag and drop an instance of ImageViewer to the form. If you do not have ImageViewer in your toolbox, select Tools->Add Remove Toolbox Items from the menu. Click Browse and then select Leadtools.Controls.WinForms.DLL from "<LEADTOOLS_INSTALLDIR>\Bin\DotNet4\Win32" and then click Open and then click OK.
Switch to Form1 code view (right-click Form1 in the solution explorer then select View Code ) and add the following lines at the beginning of the file:
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.Controls
using Leadtools;using Leadtools.Codecs;using Leadtools.Controls;
Add an event handler to the Form1 Load event and add the following code:
' the RasterCodecs object for loading/saving imagesPrivate codecs As RasterCodecsPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load' Initialize a new RasterCodecs objectcodecs = New RasterCodecs()End Sub
// the RasterCodecs object for loading/saving imagesprivate RasterCodecs codecs;private void Form1_Load(object sender, System.EventArgs e){// Initialize a new RasterCodecs objectcodecs = new RasterCodecs();}
Double-click the button1 Button on the form to add the event handler for it and add the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click' show the open file dialogDim dlg As New OpenFileDialogdlg.Filter = "All Files|*.*"If (dlg.ShowDialog(Me) = DialogResult.OK) ThenTry' try to load the fileDim tempImage As RasterImage = codecs.Load(dlg.FileName)' set the image into the viewerImageViewer1.Image = tempImageCatch ex As ExceptionMessageBox.Show(Me, ex.Message)End TryEnd IfEnd Sub
private void button1_Click(object sender, System.EventArgs e){// show the open file dialogOpenFileDialog dlg = new OpenFileDialog();dlg.Filter = "All Files|*.*";if(dlg.ShowDialog(this) == DialogResult.OK){try{// try to load the fileRasterImage tempImage = codecs.Load(dlg.FileName);// set the image into the viewerimageViewer1.Image = tempImage;}catch(Exception ex){MessageBox.Show(this, ex.Message);}}}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
