C# Класс 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 );
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
FromFile ( string fileName ) : Bitmap
ImageDecoder ( ) : System

Описание методов

DecodeFromFile() публичный статический метод

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.
Результат System.Drawing.Bitmap

DecodeFromFile() публичный статический метод

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.
Результат System.Drawing.Bitmap

RegisterDecoder() публичный статический метод

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.
Результат void