using SkiaSharp;
namespace Jellyfin.Drawing.Skia;
///
/// The SkiaSharp extensions.
///
public static class SkiaExtensions
{
///
/// Draws an SKBitmap on the canvas with specified SkSamplingOptions.
///
/// The SKCanvas to draw on.
/// The SKBitmap to draw.
/// The destination SKRect.
/// The SKSamplingOptions to use for rendering.
/// Optional SKPaint to apply additional effects or styles.
public static void DrawBitmap(this SKCanvas canvas, SKBitmap bitmap, SKRect dest, SKSamplingOptions options, SKPaint? paint = null)
{
using var image = SKImage.FromBitmap(bitmap);
canvas.DrawImage(image, dest, options, paint);
}
///
/// Draws an SKBitmap on the canvas at the specified coordinates with the given SkSamplingOptions.
///
/// The SKCanvas to draw on.
/// The SKBitmap to draw.
/// The x-coordinate where the bitmap will be drawn.
/// The y-coordinate where the bitmap will be drawn.
/// The SKSamplingOptions to use for rendering.
/// Optional SKPaint to apply additional effects or styles.
public static void DrawBitmap(this SKCanvas canvas, SKBitmap bitmap, float x, float y, SKSamplingOptions options, SKPaint? paint = null)
{
using var image = SKImage.FromBitmap(bitmap);
canvas.DrawImage(image, x, y, options, paint);
}
///
/// Draws an SKBitmap on the canvas using a specified source rectangle, destination rectangle,
/// and optional paint, with the given SkSamplingOptions.
///
/// The SKCanvas to draw on.
/// The SKBitmap to draw.
///
/// The source SKRect defining the portion of the bitmap to draw.
///
///
/// The destination SKRect defining the area on the canvas where the bitmap will be drawn.
///
/// The SKSamplingOptions to use for rendering.
/// Optional SKPaint to apply additional effects or styles.
public static void DrawBitmap(this SKCanvas canvas, SKBitmap bitmap, SKRect source, SKRect dest, SKSamplingOptions options, SKPaint? paint = null)
{
using var image = SKImage.FromBitmap(bitmap);
canvas.DrawImage(image, source, dest, options, paint);
}
}