Table of Contents

Class PbmEncoder

Namespace
SixLabors.ImageSharp.Formats.Pbm
Assembly
SixLabors.ImageSharp.dll

Image encoder for writing an image to a stream as PGM, PBM or PPM bitmap. These images are from the family of PNM images.

The PNM formats are a fairly simple image format. They share a plain text header, consisting of: signature, width, height and max_pixel_value only. The pixels follow thereafter and can be in plain text decimals separated by spaces, or binary encoded.

  • PBMBlack and white images, with 1 representing black and 0 representing white.
  • PGMGrayscale images, scaling from 0 to max_pixel_value, 0 representing black and max_pixel_value representing white.
  • PPMColor images, with RGB pixels (in that order), with 0 representing black and 2 representing full color.
The specification of these images is found at http://netpbm.sourceforge.net/doc/pnm.html.
public sealed class PbmEncoder : ImageEncoder, IImageEncoder
Inheritance
PbmEncoder
Implements
Inherited Members

Constructors

PbmEncoder()

public PbmEncoder()

Properties

ColorType

Gets the Color type of the resulting image.

public PbmColorType? ColorType { get; init; }

Property Value

PbmColorType?

ComponentType

Gets the data type of the pixel components.

public PbmComponentType? ComponentType { get; init; }

Property Value

PbmComponentType?

Encoding

Gets the encoding of the pixels.

public PbmEncoding? Encoding { get; init; }

Property Value

PbmEncoding?

Methods

Encode<TPixel>(Image<TPixel>, Stream, CancellationToken)

Encodes the image to the specified stream from the Image<TPixel>.

protected override void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel<TPixel>

Parameters

image Image<TPixel>

The Image<TPixel> to encode from.

stream Stream

The Stream to encode the image data to.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Type Parameters

TPixel

The pixel format.

Remarks

This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use.