C# Class AForge.Imaging.Formats.ImageDecoder

Image decoder to decode different custom image file formats.

The class represent a help class, which simplifies decoding of image files finding appropriate image decoder automatically (using list of registered image decoders). Instead of using required image decoder directly, users may use this class, which will find required decoder by file's extension.

By default the class registers on its own all decoders, which are available in AForge.Imaging.Formats library. If user has implementation of his own image decoders, he needs to register them using RegisterDecoder method to be able to use them through the ImageDecoder class.

If the class can not find appropriate decode in the list of registered decoders, it passes file to .NET's image decoder for decoding.

Sample usage:

// sample file name string fileName = "myFile.pnm"; // decode image file Bitmap = ImageDecoder.DecodeFromFile( fileName );
Mostra file Open project: holisticware-admin/MonoVersal.AForgeNET

Public Methods

Method Description
DecodeFromFile ( string fileName ) : Bitmap

Decode first frame for the specified file.

The method uses table of registered image decoders to find the one, which should be used for the specified file. If there is not appropriate decoder found, the method uses default .NET's image decoding routine (see System.Drawing.Image.FromFile( string )).

DecodeFromFile ( string fileName, ImageInfo &imageInfo ) : Bitmap

Decode first frame for the specified file.

The method uses table of registered image decoders to find the one, which should be used for the specified file. If there is not appropriate decoder found, the method uses default .NET's image decoding routine (see System.Drawing.Image.FromFile( string )).

RegisterDecoder ( string fileExtension, IImageDecoder decoder ) : void

Register image decoder for a specified file extension.

The method allows to register image decoder object, which should be used to decode images from files with the specified extension.

Private Methods

Method Description
FromFile ( string fileName ) : Bitmap
ImageDecoder ( ) : System

Method Details

DecodeFromFile() public static method

Decode first frame for the specified file.

The method uses table of registered image decoders to find the one, which should be used for the specified file. If there is not appropriate decoder found, the method uses default .NET's image decoding routine (see System.Drawing.Image.FromFile( string )).

public static DecodeFromFile ( string fileName ) : Bitmap
fileName string File name to read image from.
return System.Drawing.Bitmap

DecodeFromFile() public static method

Decode first frame for the specified file.

The method uses table of registered image decoders to find the one, which should be used for the specified file. If there is not appropriate decoder found, the method uses default .NET's image decoding routine (see System.Drawing.Image.FromFile( string )).

public static DecodeFromFile ( string fileName, ImageInfo &imageInfo ) : Bitmap
fileName string File name to read image from.
imageInfo ImageInfo Information about the decoded image.
return System.Drawing.Bitmap

RegisterDecoder() public static method

Register image decoder for a specified file extension.

The method allows to register image decoder object, which should be used to decode images from files with the specified extension.

public static RegisterDecoder ( string fileExtension, IImageDecoder decoder ) : void
fileExtension string File extension to register decoder for ("bmp", for example).
decoder IImageDecoder Image decoder to use for the specified file extension.
return void