This method loads image data from a file.
Public Function LoadImageFromFile(Val As LoadFileType) As Image
public Image LoadImageFromFile(LoadFileType Val) ;
Parameters
Val
The format of the image to be
loaded.
The value is of type LoadFileType
Return Value
Returns the loaded image if successful.
Explanation
The LoadImageFromFile method loads image data from a file. The FileName property sets the file to be loaded. If successful, the loaded image is returned. If the image is a multi-page image file, set the page to be loaded in the LoadPage property.
Executing the LoadImageFromFile method will set the image information in the same properties as executing the GetImageFileType method.
16 bit BMP and TIFF files:
16 bit BMP and TIFF files can be loaded but the loaded image data
will converted to 32 bit image data. Saving the data will result in
a 32 bit image.
ImageKit.NET Plugin:
Because standard .NET Framework does not support the following
image formats, the ImageKit.NET Plugin (Dll files) are required
when using JPEG2000, FPX, PCX, DXF, SVG, or SXF formats.
Regarding FlashPix:
Flashpix image files are multi-resolution image files with a tiled
composition. Flashpix files store image data in a hierarchy from
the original image at the highest level. Each subsequent level
contains the same image with horizontal and vertical resolution
half that of the image in the level above. This allows editing and
printing at the optimum resolution. Each resolution image is
divided in to 64x64 tiles. Each tiled image can be uncompressed,
JPEG compression, or single color compression.
Example
The following sample code loads the image data from a file and shows it to the PictureBox.
[Visual Basic.NET] Dim CancelFlag As Boolean Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Ik_File As Newtone.ImageKit.WPF.IkFile Dim LoadImg As Image CancelFlag = False Ik_File = New Newtone.ImageKit.WPF.IkFile AddHandler Ik_File.Progress, AddressOf Me.File_Progress Ik_File.FileName = Ik_File.OpenFileDialog() LoadImg = Ik_File.LoadImageFromFile(Newtone.ImageKit.LoadFileType.Load) If LoadImg = Nothing Then Exit Sub PictureBox1.Image = LoadImg End Sub 'Cancel button Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click CancelFlag = True End Sub 'Generates the Progress event Private Sub File_Progress(ByVal sender As Object, ByVal e As Newtone.ImageKit.ProgressEventArgs) ProgressBar1.Value = e.Percent 'To accept a cancel Application.DoEvents() If CancelFlag = True Then e.Cancel = True 'Cancel Else e.Cancel = False End If End Sub [Visual C#.NET] private bool CancelFlag; private void button1_Click(object sender, System.EventArgs e) { Newtone.ImageKit.WPF.IkFile Ik_File = new Newtone.ImageKit.WPF.IkFile(); Ik_File.Progress += new Newtone.ImageKit.ProgressEventHandler(File_Progress); CancelFlag = false; Ik_File.FileName = Ik_File.OpenFileDialog(); Image LoadImg = Ik_File.LoadImageFromFile(Newtone.ImageKit.LoadFileType.Load); if (LoadImg == null) return; pictureBox1.Image = LoadImg; } //Cancel button private void button2_Click(object sender, System.EventArgs e) { CancelFlag = true; } //Generates progress event private void File_Progress(object sender, Newtone.ImageKit.ProgressEventArgs e) { progressBar1.Value = e.Percent; //To accept a cancel
Application.DoEvents(); if (CancelFlag) e.Cancel = true; // Cancel else e.Cancel = false; }