Table of Contents

Class ColorspaceConverter

Namespace
VisioForge.Core.Helpers
Assembly
VisioForge.Core.dll

Provides methods for converting between different color space formats such as RGB, RGBA, ARGB, BGRA, YUV, and others. The frame conversions run natively in VisioForge_VAP: Apple vImage first on macOS, Mac Catalyst and iOS, libyuv first everywhere else, FFmpeg swscale for the rest. The MFPX conversions (Windows) run on IPP in VisioForge_MFPX on x86 and x64, and through VisioForge_VAP (VisioForge_VAP_arm64.dll) on Windows on Arm.

public static class ColorspaceConverter

Inheritance

Inherited Members

Methods

ARGBToBGRA(nint, int, nint, int, int, int, BaseContext?)

Converts image data from ARGB format (Alpha, Red, Green, Blue) to BGRA format (Blue, Green, Red, Alpha).

public static void ARGBToBGRA(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source ARGB image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for BGRA image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

ARGBToRGB(nint, int, nint, int, int, int, BaseContext?)

Converts ARGB image data (4 bytes per pixel) to RGB format (3 bytes per pixel), discarding the alpha channel.

public static void ARGBToRGB(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source ARGB image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for RGB image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

BGR24ToBGRA(nint, nint, int, int, byte)

Converts BGR24 format (3 bytes per pixel) to BGRA format (4 bytes per pixel) with specified alpha value.

public static void BGR24ToBGRA(nint srcPixels, nint dstPixels, int width, int height, byte alpha)

Parameters

srcPixels nint

Pointer to the source BGR24 image data.

dstPixels nint

Pointer to the destination buffer for BGRA image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

alpha byte

The alpha value (0-255) to apply to all pixels.

BGRAToARGB(nint, int, nint, int, int, int, BaseContext?)

Converts image data from BGRA format (Blue, Green, Red, Alpha) to ARGB format (Alpha, Red, Green, Blue).

public static void BGRAToARGB(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source BGRA image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for ARGB image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

BGRToBGRA(nint, int, nint, int, int, int, BaseContext?)

Converts BGR image data (3 bytes per pixel) to BGRA format (4 bytes per pixel) with full opacity (alpha = 255).

public static void BGRToBGRA(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source BGR image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for BGRA image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

BGRToRGBA(nint, int, nint, int, int, int, BaseContext?)

Converts BGR image data (3 bytes per pixel) to RGBA format (4 bytes per pixel) with full opacity (alpha = 255). Swaps red and blue channels during conversion.

public static void BGRToRGBA(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source BGR image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for RGBA image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

NV12ToRGBSlow(nint, int, int, int, nint, int)

Converts NV12 YUV format to RGB format using software conversion (slower than hardware-accelerated methods). NV12 format stores Y plane followed by interleaved UV plane.

public static void NV12ToRGBSlow(nint nv12Data, int stride, int width, int height, nint rgbData, int rgbStride)

Parameters

nv12Data nint

Pointer to the source NV12 data containing Y plane and UV plane.

stride int

The stride of the NV12 data (bytes per row).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

rgbData nint

Pointer to the destination buffer for RGB data.

rgbStride int

The stride of the RGB data (bytes per row).

RGB24ToBGR24(nint, nint, int, int, int)

Converts RGB24 format to BGR24 format by swapping the red and blue channels.

public static void RGB24ToBGR24(nint srcPixels, nint dstPixels, int width, int height, int stride)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for BGR24 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

stride int

The number of bytes per row in both source and destination images (including padding).

RGB24ToRGB32(nint, nint, int, int)

Converts RGB24 format (3 bytes per pixel) to RGB32 format (4 bytes per pixel with unused alpha byte).

public static void RGB24ToRGB32(nint srcPixels, nint dstPixels, int width, int height)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for RGB32 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

Remarks

The fourth byte of every destination pixel is left as it was (on Windows on Arm it is set to 255); use RGB24ToRGBA for a defined alpha.

RGB24ToRGBA(nint, nint, int, int, byte)

Converts RGB24 format (3 bytes per pixel) to RGBA format (4 bytes per pixel) with specified alpha value.

public static void RGB24ToRGBA(nint srcPixels, nint dstPixels, int width, int height, byte alpha)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for RGBA image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

alpha byte

The alpha value (0-255) to apply to all pixels.

RGB24ToUYVY_HDYC(nint, nint, int, int, int, int)

Converts RGB24 format to UYVY (also known as HDYC) format. UYVY is a YUV 4:2:2 format that stores two pixels in 4 bytes as U Y0 V Y1 pattern.

public static void RGB24ToUYVY_HDYC(nint pSource, nint pDest, int width, int height, int srcStride, int destStride)

Parameters

pSource nint

Pointer to the source RGB24 image data.

pDest nint

Pointer to the destination buffer for UYVY image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

destStride int

The number of bytes per row in the destination image (including padding).

Remarks

On Windows on Arm an odd width is not converted.

RGB24ToYUY2(nint, nint, int, int, int, int)

Converts RGB24 format to YUY2 (YUV 4:2:2) format. YUY2 stores two pixels in 4 bytes as Y0 U Y1 V pattern.

public static void RGB24ToYUY2(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for YUY2 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

Remarks

On Windows on Arm an odd width is not converted.

RGB24ToYV12(nint, nint, int, int, int)

Converts RGB24 format to YV12 (YUV 4:2:0 planar) format. YV12 stores Y plane followed by V and U planes at quarter resolution.

public static void RGB24ToYV12(nint srcPixels, nint dstPixels, int width, int height, int srcStride)

Parameters

srcPixels nint

Pointer to the source RGB24 image data in B, G, R byte order.

dstPixels nint

Pointer to the destination buffer for YV12 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

Remarks

On Windows on Arm an odd width or height is not converted. Elsewhere, at an odd height, the picture's bottom row is left out: the last row of the Y plane and the end of each colour plane keep what the buffer held.

RGB32ToRGB24(nint, nint, int, int)

Converts RGB32 format (4 bytes per pixel with unused alpha) to RGB24 format (3 bytes per pixel).

public static void RGB32ToRGB24(nint srcPixels, nint dstPixels, int width, int height)

Parameters

srcPixels nint

Pointer to the source RGB32 image data.

dstPixels nint

Pointer to the destination buffer for RGB24 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

RGB32ToUYVY_HDYC(nint, nint, int, int, int, int)

Converts RGB32 format to UYVY (also known as HDYC) format. UYVY is a YUV 4:2:2 format that stores two pixels in 4 bytes as U Y0 V Y1 pattern.

public static void RGB32ToUYVY_HDYC(nint pSource, nint pDest, int width, int height, int srcStride, int destStride)

Parameters

pSource nint

Pointer to the source RGB32 image data.

pDest nint

Pointer to the destination buffer for UYVY image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

destStride int

The number of bytes per row in the destination image (including padding).

Remarks

On Windows on Arm an odd width is not converted.

RGB32ToYUY2(nint, nint, int, int, int, int)

Converts RGB32 format to YUY2 (YUV 4:2:2) format. YUY2 stores two pixels in 4 bytes as Y0 U Y1 V pattern.

public static void RGB32ToYUY2(nint pSource, nint pDest, int width, int height, int srcStride, int destStride)

Parameters

pSource nint

Pointer to the source RGB32 image data.

pDest nint

Pointer to the destination buffer for YUY2 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

destStride int

The number of bytes per row in the destination image (including padding).

Remarks

On Windows on Arm an odd width is not converted.

RGBAToARGB(nint, int, nint, int, int, int, BaseContext?)

Converts image data from RGBA format (Red, Green, Blue, Alpha) to ARGB format (Alpha, Red, Green, Blue).

public static void RGBAToARGB(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source RGBA image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for ARGB image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

RGBAToBGRA(nint, int, nint, int, int, int, BaseContext?)

Converts image data from RGBA format (Red, Green, Blue, Alpha) to BGRA format (Blue, Green, Red, Alpha), or back: the swap is the same both ways.

public static void RGBAToBGRA(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source RGBA image data.

inputStride int

The number of bytes per row in the source image (including padding); negative for a bottom-up image.

outputPtr nint

Pointer to the destination buffer for BGRA image data.

outputStride int

The number of bytes per row in the destination image (including padding); negative for a bottom-up image.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

RGBAToCairo32(byte[], double)

Converts RGBA image data to Cairo32 format with pre-multiplied alpha. Cairo32 format stores pixels in pre-multiplied BGRA order for efficient rendering.

public static byte[] RGBAToCairo32(byte[] data, double alpha)

Parameters

data byte[]

The source RGBA image data as a byte array.

alpha double

Additional alpha multiplier (0.0 to 1.0) to apply to all pixels.

Returns

byte[]

A new byte array containing the converted Cairo32 format data.

RGBAToCairo32Ptr(byte[], double)

Converts RGBA image data to Cairo32 format and returns a pointer to the converted data. The caller is responsible for freeing the allocated memory using Marshal.FreeHGlobal.

public static nint RGBAToCairo32Ptr(byte[] data, double alpha)

Parameters

data byte[]

The source RGBA image data as a byte array, not premultiplied - for a premultiplied SKBitmap use VisioForge.Core.Helpers.ColorspaceConverter.RGBAToCairo32Ptr(SkiaSharp.SKBitmap,System.Double).

alpha double

Additional alpha multiplier (0.0 to 1.0) to apply to all pixels.

Returns

nint

A pointer to the newly allocated Cairo32 format data. Must be freed by the caller.

RGBAToCairo32Ptr(SKBitmap, double)

Converts an RGBA bitmap to Cairo32 format - premultiplied BGRA - and returns a pointer to the converted data. A bitmap that is premultiplied already (as SkiaSharp decodes and copies them) is not premultiplied a second time. The caller is responsible for freeing the allocated memory using Marshal.FreeHGlobal.

public static nint RGBAToCairo32Ptr(SKBitmap bitmap, double alpha)

Parameters

bitmap SKBitmap

The source bitmap, SkiaSharp.SKColorType.Rgba8888.

alpha double

Additional alpha multiplier (0.0 to 1.0) to apply to all pixels.

Returns

nint

A pointer to the newly allocated Cairo32 format data. Must be freed by the caller.

RGBToARGB(nint, int, nint, int, int, int, BaseContext?)

Converts RGB image data (3 bytes per pixel) to ARGB format (4 bytes per pixel) with full opacity (alpha = 255).

public static void RGBToARGB(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source RGB image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for ARGB image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

RGBToBGRA(nint, int, nint, int, int, int, BaseContext?)

Converts RGB image data (3 bytes per pixel) to BGRA format (4 bytes per pixel) with full opacity (alpha = 255). Swaps red and blue channels during conversion.

public static void RGBToBGRA(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source RGB image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for BGRA image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

RGBToRGBA(byte[], nint, int, int, int, BaseContext?)

Converts RGB image data (3 bytes per pixel) to RGBA format (4 bytes per pixel) with full opacity. This overload accepts input data as a byte array.

public static void RGBToRGBA(byte[] inputData, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputData byte[]

The source RGB image data as a byte array.

outputPtr nint

Pointer to the destination buffer for RGBA image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

RGBToRGBA(nint, int, nint, int, int, int, BaseContext?)

Converts RGB image data (3 bytes per pixel) to RGBA format (4 bytes per pixel) with full opacity (alpha = 255).

public static void RGBToRGBA(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height, BaseContext? context = null)

Parameters

inputPtr nint

Pointer to the source RGB image data.

inputStride int

The number of bytes per row in the source image (including padding).

outputPtr nint

Pointer to the destination buffer for RGBA image data.

outputStride int

The number of bytes per row in the destination image (including padding).

width int

The width of the image in pixels.

height int

The height of the image in pixels.

context BaseContext?

Optional context for error logging and diagnostics.

TryBGR24ToBGRA(nint, nint, int, int, int, int, byte)

Converts BGR24 to BGRA as VisioForge.Core.Helpers.ColorspaceConverter.BGR24ToBGRA(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Byte) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryBGR24ToBGRA(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride, byte alpha)

Parameters

srcPixels nint

Pointer to the source BGR24 image data.

dstPixels nint

Pointer to the destination buffer for BGRA image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

alpha byte

The alpha value (0-255) to apply to all pixels.

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row), in which case dstPixels holds no defined image. On Windows on Arm with a VisioForge_VAP older than 2026.10.25, an alpha other than 255 is refused the same way.

TryRGB24ToBGR24(nint, nint, int, int, int)

Converts RGB24 to BGR24 as VisioForge.Core.Helpers.ColorspaceConverter.RGB24ToBGR24(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryRGB24ToBGR24(nint srcPixels, nint dstPixels, int width, int height, int stride)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for BGR24 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

stride int

The number of bytes per row in both source and destination images (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row), in which case dstPixels holds no defined image.

TryRGB24ToRGB32(nint, nint, int, int, int, int)

Converts RGB24 to RGB32 as VisioForge.Core.Helpers.ColorspaceConverter.RGB24ToRGB32(System.IntPtr,System.IntPtr,System.Int32,System.Int32) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryRGB24ToRGB32(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for RGB32 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row), in which case dstPixels holds no defined image.

Remarks

The fourth byte of every destination pixel is left as it was (on Windows on Arm it is set to 255); use RGB24ToRGBA for a defined alpha.

TryRGB24ToRGBA(nint, nint, int, int, int, int, byte)

Converts RGB24 to RGBA as VisioForge.Core.Helpers.ColorspaceConverter.RGB24ToRGBA(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Byte) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryRGB24ToRGBA(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride, byte alpha)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for RGBA image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

alpha byte

The alpha value (0-255) to apply to all pixels.

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row), in which case dstPixels holds no defined image. On Windows on Arm with a VisioForge_VAP older than 2026.10.25, an alpha other than 255 is refused the same way.

TryRGB24ToUYVY_HDYC(nint, nint, int, int, int, int)

Converts RGB24 to UYVY as VisioForge.Core.Helpers.ColorspaceConverter.RGB24ToUYVY_HDYC(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryRGB24ToUYVY_HDYC(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for UYVY image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row; on Windows on Arm also an odd width), in which case dstPixels holds no defined image.

TryRGB24ToYUY2(nint, nint, int, int, int, int)

Converts RGB24 to YUY2 as VisioForge.Core.Helpers.ColorspaceConverter.RGB24ToYUY2(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryRGB24ToYUY2(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for YUY2 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row; on Windows on Arm also an odd width), in which case dstPixels holds no defined image.

TryRGB24ToYV12(nint, nint, int, int, int)

Converts RGB24 to YV12 as VisioForge.Core.Helpers.ColorspaceConverter.RGB24ToYV12(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32) does, with the RGB24 row stride given explicitly, and reports whether the conversion succeeded. The YV12 image is the Y plane, then V, then U, contiguous, with rows of width and width / 2 bytes; width and height must be even.

public static bool TryRGB24ToYV12(nint srcPixels, nint dstPixels, int width, int height, int srcStride)

Parameters

srcPixels nint

Pointer to the source RGB24 image data.

dstPixels nint

Pointer to the destination buffer for YV12 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero, negative or odd size, a stride shorter than the row), in which case dstPixels holds no defined image.

TryRGB32ToRGB24(nint, nint, int, int, int, int)

Converts RGB32 to RGB24 as VisioForge.Core.Helpers.ColorspaceConverter.RGB32ToRGB24(System.IntPtr,System.IntPtr,System.Int32,System.Int32) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryRGB32ToRGB24(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride)

Parameters

srcPixels nint

Pointer to the source RGB32 image data.

dstPixels nint

Pointer to the destination buffer for RGB24 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row), in which case dstPixels holds no defined image.

TryRGB32ToUYVY_HDYC(nint, nint, int, int, int, int)

Converts RGB32 to UYVY as VisioForge.Core.Helpers.ColorspaceConverter.RGB32ToUYVY_HDYC(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryRGB32ToUYVY_HDYC(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride)

Parameters

srcPixels nint

Pointer to the source RGB32 image data.

dstPixels nint

Pointer to the destination buffer for UYVY image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row; on Windows on Arm also an odd width), in which case dstPixels holds no defined image.

TryRGB32ToYUY2(nint, nint, int, int, int, int)

Converts RGB32 to YUY2 as VisioForge.Core.Helpers.ColorspaceConverter.RGB32ToYUY2(System.IntPtr,System.IntPtr,System.Int32,System.Int32,System.Int32,System.Int32) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryRGB32ToYUY2(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride)

Parameters

srcPixels nint

Pointer to the source RGB32 image data.

dstPixels nint

Pointer to the destination buffer for YUY2 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row; on Windows on Arm also an odd width), in which case dstPixels holds no defined image.

TryYUY2ToRGB24(nint, nint, int, int, int, int)

Converts YUY2 to RGB24 as VisioForge.Core.Helpers.ColorspaceConverter.YUY2ToRGB24(System.IntPtr,System.IntPtr,System.Int32,System.Int32) does, with every stride given explicitly, and reports whether the conversion succeeded.

public static bool TryYUY2ToRGB24(nint srcPixels, nint dstPixels, int width, int height, int srcStride, int dstStride)

Parameters

srcPixels nint

Pointer to the source YUY2 image data.

dstPixels nint

Pointer to the destination buffer for RGB24 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

srcStride int

The number of bytes per row in the source image (including padding).

dstStride int

The number of bytes per row in the destination image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero or negative size, a stride shorter than the row; on Windows on Arm also an odd width), in which case dstPixels holds no defined image.

TryYV12ToRGB24(nint, nint, int, int, int)

Converts YV12 to RGB24 as VisioForge.Core.Helpers.ColorspaceConverter.YV12ToRGB24(System.IntPtr,System.IntPtr,System.Int32,System.Int32) does, with the RGB24 row stride given explicitly, and reports whether the conversion succeeded. The YV12 image is the Y plane, then V, then U, contiguous, with rows of width and width / 2 bytes; width and height must be even.

public static bool TryYV12ToRGB24(nint srcPixels, nint dstPixels, int width, int height, int dstStride)

Parameters

srcPixels nint

Pointer to the source YV12 image data.

dstPixels nint

Pointer to the destination buffer for RGB24 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

dstStride int

The number of bytes per row in the destination image (including padding).

Returns

bool

true if the image was converted; false if the native library rejected the arguments (a null pointer, a zero, negative or odd size, a stride shorter than the row), in which case dstPixels holds no defined image.

YUY2ToRGB24(nint, nint, int, int)

Converts YUY2 (YUV 4:2:2) format to RGB24 format. YUY2 stores two pixels in 4 bytes as Y0 U Y1 V pattern.

public static void YUY2ToRGB24(nint srcPixels, nint dstPixels, int width, int height)

Parameters

srcPixels nint

Pointer to the source YUY2 image data.

dstPixels nint

Pointer to the destination buffer for RGB24 image data.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

Remarks

On Windows on Arm an odd width is not converted.

YV12ToRGB24(nint, nint, int, int)

Converts YV12 (YUV 4:2:0 planar) format to RGB24 format. YV12 stores Y plane followed by V and U planes at quarter resolution.

public static void YV12ToRGB24(nint srcPixels, nint dstPixels, int width, int height)

Parameters

srcPixels nint

Pointer to the source YV12 image data containing Y, V, and U planes.

dstPixels nint

Pointer to the destination buffer for RGB24 image data, written in B, G, R byte order.

width int

The width of the image in pixels.

height int

The height of the image in pixels.

Remarks

On Windows on Arm an odd width or height is not converted.