AForge.Imaging.Formats 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 method to be able to use them through the 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 ); Register image decoder for a specified file extension. File extension to register decoder for ("bmp", for example). Image decoder to use for the specified file extension. The method allows to register image decoder object, which should be used to decode images from files with the specified extension. Decode first frame for the specified file. File name to read image from. Return decoded image. In the case if file format support multiple frames, the method return the first frame. 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 ). Decode first frame for the specified file. File name to read image from. Information about the decoded image. Return decoded image. In the case if file format support multiple frames, the method return the first frame. 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 ). Information about PNM image's frame. Information about image's frame. This is a base class, which keeps basic information about image, like its width, height, etc. Classes, which inherit from this, may define more properties describing certain image formats. Image's width. Image's height. Number of bits per image's pixel. Frame's index. Total frames in the image. Initializes a new instance of the class. Initializes a new instance of the class. Image's width. Image's height. Number of bits per image's pixel. Frame's index. Total frames in the image. Creates a new object that is a copy of the current instance. A new object that is a copy of this instance. Image's width. Image's height. Number of bits per image's pixel. Frame's index. Some image formats support storing multiple frames in one image file. The property specifies index of a particular frame. Total frames in the image. Some image formats support storing multiple frames in one image file. The property specifies total number of frames in image file. Initializes a new instance of the class. Initializes a new instance of the class. Image's width. Image's height. Number of bits per image's pixel. Frame's index. Total frames in the image. Creates a new object that is a copy of the current instance. A new object that is a copy of this instance. PNM file version (format), [1, 6]. Maximum pixel's value in source PNM image. The value is used to scale image's data converting them from original data range to the range of supported bits per pixel format. PNM image format decoder. The PNM (an acronym derived from "Portable Any Map") format is an abstraction of the PBM, PGM and PPM formats. I.e. the name "PNM" refers collectively to PBM (binary images), PGM (grayscale images) and PPM (color image) image formats. Image in PNM format can be found in different scientific databases and laboratories, for example Yale Face Database and AT&T Face Database. Only PNM images of P5 (binary encoded PGM) and P6 (binary encoded PPM) formats are supported at this point. The maximum supported pixel value is 255 at this point. The class supports only one-frame PNM images. As it is specified in format specification, the multi-frame PNM images has appeared starting from 2000. Image decoder interface, which specifies set of methods, which should be implemented by image decoders for different file formats. The interface specifies set of methods, which are suitable not only for simple one-frame image formats. The interface also defines methods to work with image formats designed to store multiple frames and image formats which provide different type of image description (like acquisition parameters, etc). Decode first frame of image from the specified stream. Source stream, which contains encoded image. Returns decoded image frame. For one-frame image formats the method is supposed to decode single available frame. For multi-frame image formats the first frame should be decoded. Implementations of this method may throw exception to report about unrecognized image format, exception to report about incorrectly formatted image or exception to report if certain formats are not supported. Open specified stream. Stream to open. Returns number of images found in the specified stream. Implementation of this method is supposed to read image's header, checking for correct image format and reading its atributes. Implementations of this method may throw exception to report about unrecognized image format, exception to report about incorrectly formatted image or exception to report if certain formats are not supported. Decode specified frame. Image frame to decode. Receives information about decoded frame. Returns decoded frame. Implementations of this method may throw exception in the case if no image stream was opened previously, in the case if stream does not contain frame with specified index or exception to report about incorrectly formatted image. Close decoding of previously opened stream. Implementations of this method don't close stream itself, but just close decoding cleaning all associated data with it. Decode first frame of PNM image. Source stream, which contains encoded image. Returns decoded image frame. Not a PNM image format. Format of the PNM image is not supported. The stream contains invalid (broken) PNM image. Open specified stream. Stream to open. Returns number of images found in the specified stream. Not a PNM image format. Format of the PNM image is not supported. The stream contains invalid (broken) PNM image. Decode specified frame. Image frame to decode. Receives information about decoded frame. Returns decoded frame. No image stream was opened previously. Stream does not contain frame with specified index. The stream contains invalid (broken) PNM image. Close decoding of previously opened stream. The method does not close stream itself, but just closes decoding cleaning all associated data with it. Information about FITS image's frame. Initializes a new instance of the class. Initializes a new instance of the class. Image's width. Image's height. Number of bits per image's pixel. Frame's index. Total frames in the image. Creates a new object that is a copy of the current instance. A new object that is a copy of this instance. Original bits per pixel. The property specifies original number of bits per image's pixel. For FITS images the value may be equal to 8, 16, 32, -32 (32 bit image with float data type for pixel encoding), -64 (64 bit image with double data type for pixel encoding). Minimum data value found during parsing FITS image. Minimum and maximum data values are used to scale image's data converting them from original bits per pixel format to supported bits per pixel format. Maximum data value found during parsing FITS image. Minimum and maximum data values are used to scale image's data converting them from original bits per pixel format to supported bits per pixel format. Telescope used for object's observation. Object acquired during observation. Observer doing object's acquiring. Instrument used for observation. FITS image format decoder. The FITS (an acronym derived from "Flexible Image Transport System") format is an astronomical image and table format created and supported by NASA. FITS is the most commonly used in astronomy and is designed specifically for scientific data. Different astronomical organizations keep their images acquired using telescopes and other equipment in FITS format. The class extracts image frames only from the main data section of FITS file. 2D (single frame) and 3D (series of frames) data structures are supported. During image reading/parsing, its data are scaled using minimum and maximum values of the source image data. FITS tags are not used for this purpose - data are scaled from the [min, max] range found to the range of supported image format ([0, 255] for 8 bpp grayscale or [0, 65535] for 16 bpp grayscale image). Decode first frame of FITS image. Source stream, which contains encoded image. Returns decoded image frame. Not a FITS image format. Format of the FITS image is not supported. The stream contains invalid (broken) FITS image. Open specified stream. Stream to open. Returns number of images found in the specified stream. Not a FITS image format. Format of the FITS image is not supported. The stream contains invalid (broken) FITS image. Decode specified frame. Image frame to decode. Receives information about decoded frame. Returns decoded frame. No image stream was opened previously. Stream does not contain frame with specified index. The stream contains invalid (broken) FITS image. Close decoding of previously opened stream. The method does not close stream itself, but just closes decoding cleaning all associated data with it. Set of tools used internally in AForge.Imaging.Formats library. Create and initialize new grayscale image. Image width. Image height. Returns new created grayscale image. AForge.Imaging.Image.CreateGrayscaleImage() function could be used instead, which does the some. But it was not used to get rid of dependency on AForge.Imaing library. Read specified amount of bytes from the specified stream. Source sream to read data from. Buffer to read data into. Offset in buffer to put data into. Number of bytes to read. Returns total number of bytes read. It may be smaller than requested amount only in the case if end of stream was reached. This tool function guarantees that requested number of bytes was read from the source stream (.NET streams don't guarantee this and may return less bytes than it was requested). Only in the case if end of stream was reached, the function may return with less bytes read.