PDFsharp-net6

PngBuilder

Namespace: PdfSharp.BigGustave

Used to construct PNG images. Call PngBuilder.Create(Int32, Int32, Boolean) to make a new builder.

public class PngBuilder

Inheritance ObjectPngBuilder

Methods

Create(Int32, Int32, Boolean)

Create a builder for a PNG with the given width and size.

public static PngBuilder Create(int width, int height, bool hasAlphaChannel)

Parameters

width Int32

height Int32

hasAlphaChannel Boolean

Returns

PngBuilder

FromPng(Png)

Create a builder from a Png.

public static PngBuilder FromPng(Png png)

Parameters

png Png

Returns

PngBuilder

FromPngBytes(Byte[])

Create a builder from the bytes of the specified PNG image.

public static PngBuilder FromPngBytes(Byte[] png)

Parameters

png Byte[]

Returns

PngBuilder

FromBgra32Pixels(Byte[], Int32, Int32, Boolean)

Create a builder from the bytes in the BGRA32 pixel format. https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.pixelformats.bgra32

public static PngBuilder FromBgra32Pixels(Byte[] data, int width, int height, bool useAlphaChannel)

Parameters

data Byte[]
The pixels in BGRA32 format.

width Int32
The width in pixels.

height Int32
The height in pixels.

useAlphaChannel Boolean
Whether to include an alpha channel in the output.

Returns

PngBuilder

FromBgra32Pixels(Stream, Int32, Int32, Boolean)

Create a builder from the bytes in the BGRA32 pixel format. https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.pixelformats.bgra32

public static PngBuilder FromBgra32Pixels(Stream data, int width, int height, bool useAlphaChannel)

Parameters

data Stream
The pixels in BGRA32 format.

width Int32
The width in pixels.

height Int32
The height in pixels.

useAlphaChannel Boolean
Whether to include an alpha channel in the output.

Returns

PngBuilder

SetPixel(Byte, Byte, Byte, Int32, Int32)

Sets the RGB pixel value for the given column (x) and row (y).

public PngBuilder SetPixel(byte r, byte g, byte b, int x, int y)

Parameters

r Byte

g Byte

b Byte

x Int32

y Int32

Returns

PngBuilder

SetPixel(Pixel, Int32, Int32)

Set the pixel value for the given column (x) and row (y).

public PngBuilder SetPixel(Pixel pixel, int x, int y)

Parameters

pixel Pixel

x Int32

y Int32

Returns

PngBuilder

StoreText(String, String)

Allows you to store arbitrary text data in the “iTXt” international textual data chunks of the generated PNG image.

public PngBuilder StoreText(string keyword, string text)

Parameters

keyword String
A keyword identifying the text data between 1-79 characters in length. Must not start with, end with, or contain consecutive whitespace characters. Only characters in the range 32 - 126 and 161 - 255 are permitted.

text String
The text data to store. Encoded as UTF-8 that may not contain zero (0) bytes but can be zero-length.

Returns

PngBuilder

Save(SaveOptions)

Get the bytes of the PNG file for this builder.

public Byte[] Save(SaveOptions options)

Parameters

options SaveOptions

Returns

Byte[]

Save(Stream, SaveOptions)

Write the PNG file bytes to the provided stream.

public void Save(Stream outputStream, SaveOptions options)

Parameters

outputStream Stream

options SaveOptions