Class PbmEncoder
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.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp.Formats.Pbm
Assembly: SixLabors.ImageSharp.dll
Syntax
public sealed class PbmEncoder : IImageEncoder
Properties
| Improve this Doc View SourceColorType
Gets or sets the Color type of the resulting image.
Declaration
public PbmColorType? ColorType { get; set; }
Property Value
Type | Description |
---|---|
Nullable<PbmColorType> |
ComponentType
Gets or sets the data type of the pixels components.
Declaration
public PbmComponentType? ComponentType { get; set; }
Property Value
Type | Description |
---|---|
Nullable<PbmComponentType> |
Encoding
Gets or sets the Encoding of the pixels.
Declaration
public PbmEncoding? Encoding { get; set; }
Property Value
Type | Description |
---|---|
Nullable<PbmEncoding> |
Methods
| Improve this Doc View SourceEncode<TPixel>(Image<TPixel>, Stream)
Encodes the image to the specified stream from the Image<TPixel>.
Declaration
public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : struct, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel> | image | The Image<TPixel> to encode from. |
Stream | stream | The Stream to encode the image data to. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
EncodeAsync<TPixel>(Image<TPixel>, Stream, CancellationToken)
Encodes the image to the specified stream from the Image<TPixel>.
Declaration
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken)
where TPixel : struct, IPixel<TPixel>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel> | image | 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. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |