PDFsharp-net6

Png

Namespace: PdfSharp.BigGustave

A PNG image. Call Png.Open(Stream, IChunkVisitor) to open from file or bytes.

public class Png

Inheritance ObjectPng

Properties

The header data from the PNG image.

public ImageHeader Header { get; }

Property Value

ImageHeader

Width

The width of the image in pixels.

public int Width { get; }

Property Value

Int32

Height

The height of the image in pixels.

public int Height { get; }

Property Value

Int32

HasAlphaChannel

Whether the image has an alpha (transparency) layer.

public bool HasAlphaChannel { get; }

Property Value

Boolean

Methods

GetPixelIndex(Int32, Int32)

Get the palette index at the given column and row (x, y).

public int GetPixelIndex(int x, int y)

Parameters

x Int32
The x coordinate (column).

y Int32
The y coordinate (row).

Returns

Int32
The palette index of the pixel at the coordinate.

Remarks:

Pixel values are generated on demand from the underlying data to prevent holding many items in memory at once, so consumers should cache values if they’re going to be looped over many times.

GetPalette()

Gets the color palette.

public Palette GetPalette()

Returns

Palette

GetPixel(Int32, Int32)

Get the pixel at the given column and row (x, y).

public Pixel GetPixel(int x, int y)

Parameters

x Int32
The x coordinate (column).

y Int32
The y coordinate (row).

Returns

Pixel
The pixel at the coordinate.

Remarks:

Pixel values are generated on demand from the underlying data to prevent holding many items in memory at once, so consumers should cache values if they’re going to be looped over many times.

Open(Stream, IChunkVisitor)

Read the PNG image from the stream.

public static Png Open(Stream stream, IChunkVisitor chunkVisitor)

Parameters

stream Stream
The stream containing PNG data to be read.

chunkVisitor IChunkVisitor
Optional: A visitor which is called whenever a chunk is read by the library.

Returns

Png
The Png data from the stream.

Open(Stream, PngOpenerSettings)

Read the PNG image from the stream.

public static Png Open(Stream stream, PngOpenerSettings settings)

Parameters

stream Stream
The stream containing PNG data to be read.

settings PngOpenerSettings
Settings to apply when opening the PNG.

Returns

Png
The Png data from the stream.

Open(Byte[], IChunkVisitor)

Read the PNG image from the bytes.

public static Png Open(Byte[] bytes, IChunkVisitor chunkVisitor)

Parameters

bytes Byte[]
The bytes of the PNG data to be read.

chunkVisitor IChunkVisitor
Optional: A visitor which is called whenever a chunk is read by the library.

Returns

Png
The Png data from the bytes.

Open(Byte[], PngOpenerSettings)

Read the PNG image from the bytes.

public static Png Open(Byte[] bytes, PngOpenerSettings settings)

Parameters

bytes Byte[]
The bytes of the PNG data to be read.

settings PngOpenerSettings
Settings to apply when opening the PNG.

Returns

Png
The Png data from the bytes.

Open(String, IChunkVisitor)

Read the PNG from the file path.

public static Png Open(string filePath, IChunkVisitor chunkVisitor)

Parameters

filePath String
The path to the PNG file to open.

chunkVisitor IChunkVisitor
Optional: A visitor which is called whenever a chunk is read by the library.

Returns

Png
The Png data from the file.

Remarks:

This will open the file to obtain a FileStream so will lock the file during reading.

Open(String, PngOpenerSettings)

Read the PNG from the file path.

public static Png Open(string filePath, PngOpenerSettings settings)

Parameters

filePath String
The path to the PNG file to open.

settings PngOpenerSettings
Settings to apply when opening the PNG.

Returns

Png
The Png data from the file.

Remarks:

This will open the file to obtain a FileStream so will lock the file during reading.