Class PixelFormatExtensions
Provides extension methods for working with PixelFormat values.
Inherited Members
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 SourceBitsPerPixel(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. |
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.
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. |
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. |
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.
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. |
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. |
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. |
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. |