Table of Contents

Class PdfImage

Namespace
MiPdf.Images
Assembly
MiPdf.dll

A raster image that can be drawn on pages. Supported formats: JPEG (embedded unchanged), PNG (all color types and bit depths, transparency becomes a soft mask), BMP and GIF (decoded). Images are independent of documents; each document embeds an image only once, however often it is drawn.

public sealed class PdfImage
Inheritance
PdfImage
Inherited Members

Properties

AspectRatio

Width / height.

public double AspectRatio { get; }

Property Value

double

Height

Height in pixels.

public int Height { get; }

Property Value

int

Width

Width in pixels.

public int Width { get; }

Property Value

int

Methods

FromBytes(byte[])

Creates an image from JPEG, PNG, BMP or GIF data (detected by signature). JPEG is embedded as is; the others are decoded.

public static PdfImage FromBytes(byte[] data)

Parameters

data byte[]

Returns

PdfImage

FromFile(string)

Loads a JPEG, PNG, BMP or GIF file (see FromBytes(byte[])).

public static PdfImage FromFile(string path)

Parameters

path string

Returns

PdfImage

FromPixels(int, int, byte[], int, byte[]?)

Creates an image from raw 8-bit pixel data (RGB, gray or CMYK, row by row without padding), optionally with an 8-bit alpha channel.

public static PdfImage FromPixels(int width, int height, byte[] pixels, int components, byte[]? alpha = null)

Parameters

width int
height int
pixels byte[]
components int
alpha byte[]

Returns

PdfImage

FromStream(Stream)

Reads JPEG, PNG, BMP or GIF data from a stream to its end (see FromBytes(byte[])); the stream is not closed.

public static PdfImage FromStream(Stream stream)

Parameters

stream Stream

Returns

PdfImage