Show / Hide Table of Contents

Class Image

Represents an image stored in consecutive memory with utilities for handling image data and memory buffers.

Inheritance
object
Image
Implements
IDisposable
Inherited Members
object.GetType()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Images
Assembly: FFmpeg.dll
Syntax
public sealed class Image : IDisposable

Properties

View Source

Data

Gets the pointer to the raw image data.

Declaration
public nint Data { get; }
Property Value
Type Description
nint
View Source

Height

Gets the height of the image in pixels.

Declaration
public int Height { get; }
Property Value
Type Description
int
View Source

Info

Gets the information about the image, such as its dimensions, format, and alignment.

Declaration
public ImageInfo Info { get; }
Property Value
Type Description
ImageInfo
View Source

PixelFormat

Gets the pixel format of the image.

Declaration
public PixelFormat PixelFormat { get; }
Property Value
Type Description
PixelFormat
View Source

Width

Gets the width of the image in pixels.

Declaration
public int Width { get; }
Property Value
Type Description
int

Methods

View Source

ConvertTo(ImageInfo)

Converts the current image to a different pixel format and returns the result as a new Image.

Declaration
public Image ConvertTo(ImageInfo dstFormat)
Parameters
Type Name Description
ImageInfo dstFormat

The desired destination format for the conversion.

Returns
Type Description
Image

A new Image in the specified format.

Exceptions
Type Condition
FFmpegException

Thrown if the conversion fails.

View Source

Create(ImageInfo)

Creates a new Image with an allocated buffer based on the specified ImageInfo.

Declaration
public static Image Create(ImageInfo info)
Parameters
Type Name Description
ImageInfo info

The information used to describe the image.

Returns
Type Description
Image

A new Image with an allocated buffer.

View Source

Dispose()

Releases the resources used by the Image, including the underlying buffer.

Declaration
public void Dispose()
View Source

FromPixelCopy(ImageInfo, nint)

Creates a new Image by copying pixel data from the specified pointer.

Declaration
public static Image FromPixelCopy(ImageInfo info, nint data)
Parameters
Type Name Description
ImageInfo info

The image information such as dimensions and pixel format.

nint data

A pointer to the source pixel data to be copied.

Returns
Type Description
Image

A new Image with copied pixel data.

View Source

FromPixelCopy(ImageInfo, ReadOnlySpan<byte>)

Creates a new Image by copying pixel data from the specified pointer.

Declaration
public static Image FromPixelCopy(ImageInfo info, ReadOnlySpan<byte> data)
Parameters
Type Name Description
ImageInfo info

The image information such as dimensions and pixel format.

ReadOnlySpan<byte> data

A ReadOnlySpan to the source pixel data to be copied.

Returns
Type Description
Image

A new Image with copied pixel data.

View Source

FromPixels(ImageInfo, AVBuffer)

Creates a new Image from an AVBuffer containing pixel data.

Declaration
public static Image FromPixels(ImageInfo info, AVBuffer data)
Parameters
Type Name Description
ImageInfo info

The image information such as dimensions and pixel format.

AVBuffer data

The buffer that contains the pixel data.

Returns
Type Description
Image

A new Image with the specified pixel data.

View Source

FromPixels(ImageInfo, nint)

Creates a new Image using the provided pixel data pointer.

Declaration
public static Image FromPixels(ImageInfo info, nint data)
Parameters
Type Name Description
ImageInfo info

The image information such as dimensions and pixel format.

nint data

A pointer to the pixel data.

Returns
Type Description
Image

A new Image using the specified pixel data pointer.

View Source

GetLineSize(Span<int>)

Retrieves the line sizes for each plane of the image and stores them in the provided span.

Declaration
public AVResult32 GetLineSize(Span<int> lineSizes)
Parameters
Type Name Description
Span<int> lineSizes

The span to hold the line sizes for each plane of the image.

Returns
Type Description
AVResult32

An AVResult32 result indicating success or failure. If successful, the number of planes is returned.

View Source

GetPlane(int)

Gets a span representing a single image plane.

Declaration
public Span<byte> GetPlane(int index)
Parameters
Type Name Description
int index

The zero-based index of the plane to retrieve.

Returns
Type Description
Span<byte>

A Span<T> containing the bytes of the specified image plane.

Remarks

The returned span references the underlying image buffer and does not allocate additional memory. Its length corresponds to the size of the plane as determined by the current PixelFormat, Width, and Height.

Multi-planar pixel formats (such as YUV formats) expose separate planes for components like luma and chroma, while packed pixel formats expose a single plane.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown when index is less than zero or greater than or equal to Planes.

View Source

GetPlanePointers(Span<nint>)

Retrieves the pointers to each plane of the image.

Declaration
public AVResult32 GetPlanePointers(Span<nint> planePtrs)
Parameters
Type Name Description
Span<nint> planePtrs

The span to hold pointers to each plane of the image.

Returns
Type Description
AVResult32

An AVResult32 result indicating success or failure. If successful, the number of planes is returned.

View Source

GetPlanes(Span<nint>, Span<int>)

Retrieves the pointers to each plane and their respective line sizes.

Declaration
public AVResult32 GetPlanes(Span<nint> planePtrs, Span<int> lineSizes)
Parameters
Type Name Description
Span<nint> planePtrs

The span to hold pointers to each plane of the image.

Span<int> lineSizes

The span to hold the line sizes for each plane of the image.

Returns
Type Description
AVResult32

An AVResult32 result indicating success or failure. If successful, the number of planes is returned.

Implements

IDisposable
  • View Source
In this article
Back to top Generated by DocFX