Class SkiaHelper
- Namespace
- VisioForge.Core.Helpers
- Assembly
- VisioForge.Core.dll
Provides helper methods for working with SkiaSharp bitmaps, including format conversions, image transformations, and interoperability with video frames.
public static class SkiaHelperInheritance
Inherited Members
Methods
ByteArrayRGBAToSKBitmap(byte[], int, int)
Converts a byte array containing RGBA pixel data to an SKBitmap.
public static SKBitmap ByteArrayRGBAToSKBitmap(byte[] frame, int width, int height)Parameters
framebyte[]-
The byte array containing RGBA pixel data.
widthint-
The width of the image in pixels.
heightint-
The height of the image in pixels.
Returns
- SKBitmap
-
A new SKBitmap containing the converted image data.
ByteArrayRGBToSKBitmap(byte[], int, int)
Converts a byte array containing RGB pixel data to an SKBitmap. The RGB data is converted to RGBA format internally.
public static SKBitmap ByteArrayRGBToSKBitmap(byte[] frame, int width, int height)Parameters
framebyte[]-
The byte array containing RGB pixel data.
widthint-
The width of the image in pixels.
heightint-
The height of the image in pixels.
Returns
- SKBitmap
-
A new SKBitmap containing the converted image data.
FlipHorizontal(SKBitmap)
Creates a new SKBitmap that is horizontally flipped (mirrored) from the original.
public static SKBitmap FlipHorizontal(this SKBitmap bmp)Parameters
bmpSKBitmap-
The original SKBitmap to flip.
Returns
- SKBitmap
-
A new SKBitmap containing the horizontally flipped image.
FlipVertical(SKBitmap)
Creates a new SKBitmap that is vertically flipped from the original.
public static SKBitmap FlipVertical(this SKBitmap bmp)Parameters
bmpSKBitmap-
The original SKBitmap to flip.
Returns
- SKBitmap
-
A new SKBitmap containing the vertically flipped image.
RGBAToSKBitmap(nint, int, int)
Converts an unmanaged memory pointer containing RGBA pixel data to an SKBitmap.
public static SKBitmap RGBAToSKBitmap(nint data, int width, int height)Parameters
datanint-
A pointer to unmanaged memory containing RGBA pixel data.
widthint-
The width of the image in pixels.
heightint-
The height of the image in pixels.
Returns
- SKBitmap
-
A new SKBitmap containing the converted image data.
Rotate(SKBitmap, SKRotationAngle)
Rotates an SKBitmap by the specified angle.
public static SKBitmap Rotate(this SKBitmap originalBitmap, SKRotationAngle rotation)Parameters
originalBitmapSKBitmap-
The original SKBitmap to rotate.
rotationSKRotationAngle-
The rotation angle to apply (90, 180, or 270 degrees).
Returns
- SKBitmap
-
A new SKBitmap containing the rotated image with dimensions adjusted as necessary.
SaveToFile(SKBitmap, string, SKEncodedImageFormat, int)
Saves an SKBitmap to a file in the specified format.
public static void SaveToFile(this SKBitmap bitmap, string filename, SKEncodedImageFormat format = SKEncodedImageFormat.Png, int quality = 85)Parameters
bitmapSKBitmap-
The SKBitmap to save.
filenamestring-
The full path and filename where the image will be saved.
formatSKEncodedImageFormat-
The image format to use for encoding. Defaults to PNG.
qualityint-
The quality level for lossy formats (0-100). Defaults to 85. Only applicable for formats like JPEG.
ToARGB(SKBitmap, out int)
Converts an SKBitmap to an ARGB byte array and returns a pointer to the allocated memory.
public static nint ToARGB(this SKBitmap bitmap, out int length)Parameters
bitmapSKBitmap-
The SKBitmap to convert.
lengthint-
When this method returns, contains the length of the allocated memory in bytes.
Returns
- nint
-
A pointer to unmanaged memory containing the ARGB data. The caller is responsible for freeing this memory using Marshal.FreeHGlobal.
VideoFrameBGRAToSKBitmap(VideoFrameX)
Converts a VideoFrameX containing BGRA data to an SKBitmap. This is a direct copy as SKBitmap uses BGRA format internally.
public static SKBitmap VideoFrameBGRAToSKBitmap(this VideoFrameX frame)Parameters
frameVideoFrameX-
The VideoFrameX containing BGRA pixel data.
Returns
- SKBitmap
-
A new SKBitmap containing the image data.
VideoFrameRGBAToSKBitmap(VideoFrame)
Converts a VideoFrame containing RGBA data to an SKBitmap.
public static SKBitmap VideoFrameRGBAToSKBitmap(this VideoFrame frame)Parameters
frameVideoFrame-
The VideoFrame containing RGBA pixel data.
Returns
- SKBitmap
-
A new SKBitmap containing the converted image data.
VideoFrameRGBAToSKBitmap(VideoFrameX)
Converts a VideoFrameX containing RGBA data to an SKBitmap. The RGBA data is converted to BGRA format to match SKBitmap's internal format.
public static SKBitmap VideoFrameRGBAToSKBitmap(this VideoFrameX frame)Parameters
frameVideoFrameX-
The VideoFrameX containing RGBA pixel data.
Returns
- SKBitmap
-
A new SKBitmap containing the converted image data.
VideoFrameRGBToSKBitmap(VideoFrameX)
Converts a VideoFrameX containing RGB data to an SKBitmap. The RGB data is converted to BGRA format to match SKBitmap's internal format.
public static SKBitmap VideoFrameRGBToSKBitmap(this VideoFrameX frame)Parameters
frameVideoFrameX-
The VideoFrameX containing RGB pixel data.
Returns
- SKBitmap
-
A new SKBitmap containing the converted image data.