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. Supports hardware-accelerated conversions using Intel IPP when available on Windows platforms.

public static class ColorspaceConverter

Inheritance

Inherited Members

Methods

ARGBToBGRA(nint, int, nint, int, int, int)

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)

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.

ARGBToRGB(nint, int, nint, int, int, int)

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)

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.

BGRAToARGB(nint, int, nint, int, int, int)

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)

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.

BGRToBGRA(nint, int, nint, int, int, int)

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)

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.

BGRToRGBA(nint, int, nint, int, int, int)

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)

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.

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).

RGBAToARGB(nint, int, nint, int, int, int)

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)

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.

RGBAToBGRA(nint, int, nint, int, int, int)

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

public static void RGBAToBGRA(nint inputPtr, int inputStride, nint outputPtr, int outputStride, int width, int height)

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 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.

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.

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)

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)

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.

RGBToBGRA(nint, int, nint, int, int, int)

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)

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.

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

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)

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.

RGBToRGBA(nint, int, nint, int, int, int)

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)

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.