C# Class AForge.Imaging.Formats.PNMCodec

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.

Inheritance: IImageDecoder
Datei anzeigen Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Public Methods

Method Description
Close ( ) : void

Close decoding of previously opened stream.

The method does not close stream itself, but just closes decoding cleaning all associated data with it.

DecodeFrame ( int frameIndex, ImageInfo &imageInfo ) : Bitmap

Decode specified frame.

DecodeSingleFrame ( Stream stream ) : Bitmap

Decode first frame of PNM image.

Open ( Stream stream ) : int

Open specified stream.

Private Methods

Method Description
ReadHeader ( Stream stream ) : PNMImageInfo
ReadImageFrame ( Stream stream, PNMImageInfo imageInfo ) : Bitmap
ReadIntegerValue ( Stream stream ) : int
ReadP5Image ( Stream stream, int width, int height, int maxValue ) : Bitmap
ReadP6Image ( Stream stream, int width, int height, int maxValue ) : Bitmap
ReadUntilSpace ( Stream stream, byte buffer, int start ) : int
SkipSpaces ( Stream stream ) : byte

Method Details

Close() public method

Close decoding of previously opened stream.

The method does not close stream itself, but just closes decoding cleaning all associated data with it.

public Close ( ) : void
return void

DecodeFrame() public method

Decode specified frame.
No image stream was opened previously. Stream does not contain frame with specified index. The stream contains invalid (broken) PNM image.
public DecodeFrame ( int frameIndex, ImageInfo &imageInfo ) : Bitmap
frameIndex int Image frame to decode.
imageInfo ImageInfo Receives information about decoded frame.
return System.Drawing.Bitmap

DecodeSingleFrame() public method

Decode first frame of PNM image.
Not a PNM image format. Format of the PNM image is not supported. The stream contains invalid (broken) PNM image.
public DecodeSingleFrame ( Stream stream ) : Bitmap
stream Stream Source stream, which contains encoded image.
return System.Drawing.Bitmap

Open() public method

Open specified stream.
Not a PNM image format. Format of the PNM image is not supported. The stream contains invalid (broken) PNM image.
public Open ( Stream stream ) : int
stream Stream Stream to open.
return int