Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction | Help Version 19.0.7.12
|
[Visual Basic]
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Controls.WinForms
[C#]
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls.WinForms;
[Visual Basic]
' the RasterCodecs object for loading/saving images
Private codecs As RasterCodecs
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Initialize a new RasterCodecs object
codecs = New RasterCodecs()
End Sub
[C#]
// the RasterCodecs object for loading/saving images
private RasterCodecs codecs;
private void Form1_Load(object sender, System.EventArgs e)
{
// Initialize a new RasterCodecs object
codecs = new RasterCodecs();
}
[Visual Basic]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' show the open file dialog
Dim dlg As New OpenFileDialog
dlg.Filter = "All Files|*.*"
If (dlg.ShowDialog(Me) = DialogResult.OK) Then
Try
' try to load the file
Dim tempImage As RasterImage = codecs.Load(dlg.FileName)
' set the image into the viewer
RasterImageViewer1.Image = tempImage
Catch ex As Exception
MessageBox.Show(Me, ex.Message)
End Try
End If
End Sub
[C#]
private void button1_Click(object sender, System.EventArgs e)
{
// show the open file dialog
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "All Files|*.*";
if(dlg.ShowDialog(this) == DialogResult.OK)
{
try
{
// try to load the file
RasterImage tempImage = codecs.Load(dlg.FileName);
// set the image into the viewer
rasterImageViewer1.Image = tempImage;
}
catch(Exception ex)
{
MessageBox.Show(this, ex.Message);
}
}
}