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 ColorspaceConverterInheritance
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
inputPtrnint-
Pointer to the source ARGB image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for BGRA image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
inputPtrnint-
Pointer to the source ARGB image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for RGB image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
inputPtrnint-
Pointer to the source BGRA image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for ARGB image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
inputPtrnint-
Pointer to the source BGR image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for BGRA image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
inputPtrnint-
Pointer to the source BGR image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for RGBA image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
nv12Datanint-
Pointer to the source NV12 data containing Y plane and UV plane.
strideint-
The stride of the NV12 data (bytes per row).
widthint-
The width of the image in pixels.
heightint-
The height of the image in pixels.
rgbDatanint-
Pointer to the destination buffer for RGB data.
rgbStrideint-
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
inputPtrnint-
Pointer to the source RGBA image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for ARGB image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
inputPtrnint-
Pointer to the source RGBA image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for BGRA image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
databyte[]-
The source RGBA image data as a byte array.
alphadouble-
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
databyte[]-
The source RGBA image data as a byte array.
alphadouble-
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
inputPtrnint-
Pointer to the source RGB image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for ARGB image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
inputPtrnint-
Pointer to the source RGB image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for BGRA image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
inputDatabyte[]-
The source RGB image data as a byte array.
outputPtrnint-
Pointer to the destination buffer for RGBA image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
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
inputPtrnint-
Pointer to the source RGB image data.
inputStrideint-
The number of bytes per row in the source image (including padding).
outputPtrnint-
Pointer to the destination buffer for RGBA image data.
outputStrideint-
The number of bytes per row in the destination image (including padding).
widthint-
The width of the image in pixels.
heightint-
The height of the image in pixels.