C# Класс 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.

Наследование: IImageDecoder
Показать файл Открыть проект Примеры использования класса

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

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

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

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

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

Close() публичный Метод

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

DecodeFrame() публичный Метод

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

DecodeSingleFrame() публичный Метод

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

Open() публичный Метод

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