Class PixelFormatHelper
Provides helper methods for working with pixel formats.
public static class PixelFormatHelper
- Inheritance
-
PixelFormatHelper
- Inherited Members
Methods
CreateColorBuffer(MediaType, string)
Creates a VersatileBuffer filled with the specified color for the given media type.
public static VersatileBuffer CreateColorBuffer(MediaType mt, string scolor)
Parameters
mtMediaTypeThe media type describing the video format.
scolorstringThe color in string format (e.g., "#AARRGGBB").
Returns
- VersatileBuffer
A VersatileBuffer filled with the color, or null if the format is unsupported.
GetPackedImageSize(int, int, PixelFormat)
Calculates the total size, in bytes, required to store a packed image with the specified dimensions and pixel format.
public static int GetPackedImageSize(int width, int height, PixelFormat pixelFormat)
Parameters
widthintThe width of the image, in pixels. Must be a positive integer.
heightintThe height of the image, in pixels. Must be a positive integer.
pixelFormatPixelFormatThe pixel format of the image, which determines the number of planes and the stride for each plane.
Returns
- int
The total size, in bytes, of the packed image, calculated by summing the sizes of all image planes.
Remarks
The calculation takes into account the number of planes and their respective dimensions based on the provided pixel format. Ensure that the width and height parameters are valid to avoid incorrect size calculations.
GetPlaneCount(PixelFormat)
Gets the number of planes in the specified pixel format.
public static int GetPlaneCount(PixelFormat pixelFormat)
Parameters
pixelFormatPixelFormatThe pixel format.
Returns
- int
The number of planes, or 0 if unknown.
GetPlaneHeight(int, PixelFormat, int)
Gets the height of a specific plane for the specified pixel format.
public static int GetPlaneHeight(int height, PixelFormat pixelFormat, int planeIndex)
Parameters
heightintThe height of the image in pixels.
pixelFormatPixelFormatThe pixel format.
planeIndexintThe zero-based plane index.
Returns
- int
The plane height in rows, or 0 if unknown.
GetPlaneStride(int, PixelFormat, int)
Gets the stride (bytes per row) for a specific plane of the specified pixel format.
public static int GetPlaneStride(int width, PixelFormat pixelFormat, int planeIndex)
Parameters
widthintThe width of the image in pixels.
pixelFormatPixelFormatThe pixel format.
planeIndexintThe zero-based plane index.
Returns
- int
The stride in bytes, or 0 if unknown.
GetStorageBitsPerPixel(PixelFormat)
Gets the number of bits per pixel required to store the specified pixel format.
public static int GetStorageBitsPerPixel(PixelFormat pixelFormat)
Parameters
pixelFormatPixelFormatThe pixel format.
Returns
- int
The number of bits per pixel, or 0 if unknown.