Show / Hide Table of Contents

Class PixelFormatExtensions

Provides extension methods for working with PixelFormat values.

Inheritance
object
PixelFormatExtensions
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Images
Assembly: FFmpeg.dll
Syntax
public static class PixelFormatExtensions
Remarks

This class provides helpers for querying pixel format information and selecting suitable pixel formats using FFmpeg's pixel format utilities.

Methods

View Source

BitsPerPixel(PixelFormat)

Gets the bits per pixel.

Declaration
public static int BitsPerPixel(this PixelFormat pixelFormat)
Parameters
Type Name Description
PixelFormat pixelFormat

The pixel format to query.

Returns
Type Description
int

The bits per pixel.

View Source

FindBestPixelFormat(PixelFormat, out FFLoss, params ReadOnlySpan<PixelFormat>)

Finds the best matching pixel format from a list of candidates and returns the conversion loss information.

Declaration
public static PixelFormat FindBestPixelFormat(this PixelFormat pixelFormat, out FFLoss loss, params ReadOnlySpan<PixelFormat> formats)
Parameters
Type Name Description
PixelFormat pixelFormat

The source pixel format to convert from.

FFLoss loss

Receives the reported conversion loss.

ReadOnlySpan<PixelFormat> formats

The candidate pixel formats to evaluate.

Returns
Type Description
PixelFormat

The best matching pixel format, or None if no suitable format was found.

Remarks

The loss flags describe quality differences introduced when converting from the source format to the selected format.

View Source

FindBestPixelFormat(PixelFormat, bool, out FFLoss, params ReadOnlySpan<PixelFormat>)

Finds the best matching pixel format from a list of candidates while considering alpha channel preservation and returns the conversion loss.

Declaration
public static PixelFormat FindBestPixelFormat(this PixelFormat pixelFormat, bool useAlpha, out FFLoss loss, params ReadOnlySpan<PixelFormat> formats)
Parameters
Type Name Description
PixelFormat pixelFormat

The source pixel format to convert from.

bool useAlpha

true to prefer formats that preserve an alpha channel; otherwise, false.

FFLoss loss

Receives the reported conversion loss.

ReadOnlySpan<PixelFormat> formats

The candidate pixel formats to evaluate.

Returns
Type Description
PixelFormat

The best matching pixel format, or None if no suitable format was found.

View Source

FindBestPixelFormat(PixelFormat, bool, params ReadOnlySpan<PixelFormat>)

Finds the best matching pixel format from a list of candidates while considering alpha channel preservation.

Declaration
public static PixelFormat FindBestPixelFormat(this PixelFormat pixelFormat, bool useAlpha, params ReadOnlySpan<PixelFormat> formats)
Parameters
Type Name Description
PixelFormat pixelFormat

The source pixel format to convert from.

bool useAlpha

true to prefer formats that preserve an alpha channel; otherwise, false.

ReadOnlySpan<PixelFormat> formats

The candidate pixel formats to evaluate.

Returns
Type Description
PixelFormat

The best matching pixel format, or None if no suitable format was found.

View Source

FindBestPixelFormat(PixelFormat, params ReadOnlySpan<PixelFormat>)

Finds the best matching pixel format from a list of candidates.

Declaration
public static PixelFormat FindBestPixelFormat(this PixelFormat pixelFormat, params ReadOnlySpan<PixelFormat> formats)
Parameters
Type Name Description
PixelFormat pixelFormat

The source pixel format to convert from.

ReadOnlySpan<PixelFormat> formats

The candidate pixel formats to evaluate.

Returns
Type Description
PixelFormat

The best matching pixel format, or None if no suitable format was found.

Remarks

This method selects the candidate format with the lowest conversion loss according to FFmpeg's pixel format selection rules.

View Source

Parse(string)

Parses a pixel format name into a PixelFormat value.

Declaration
public static PixelFormat Parse(string name)
Parameters
Type Name Description
string name

The FFmpeg pixel format name.

Returns
Type Description
PixelFormat

The corresponding PixelFormat value, or None if the name is not recognized.

View Source

PlaneCount(PixelFormat)

Gets the number of data planes used by the pixel format.

Declaration
public static int PlaneCount(this PixelFormat pixelFormat)
Parameters
Type Name Description
PixelFormat pixelFormat

The pixel format to query.

Returns
Type Description
int

The number of planes used by the pixel format.

View Source

SwapEndianness(PixelFormat)

Swaps the byte order of a pixel format.

Declaration
public static PixelFormat SwapEndianness(this PixelFormat pixelFormat)
Parameters
Type Name Description
PixelFormat pixelFormat

The pixel format whose endianness should be swapped.

Returns
Type Description
PixelFormat

The pixel format with the opposite byte order, or None if the operation is not supported.

View Source

ToFFmpegString(PixelFormat)

Gets the FFmpeg name of the specified pixel format.

Declaration
public static string ToFFmpegString(this PixelFormat pixelFormat)
Parameters
Type Name Description
PixelFormat pixelFormat

The pixel format to convert to its FFmpeg name.

Returns
Type Description
string

The FFmpeg name of the pixel format, or null if the pixel format is not recognized.

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