| | 1 | | using SkiaSharp; |
| | 2 | |
|
| | 3 | | namespace Jellyfin.Drawing.Skia; |
| | 4 | |
|
| | 5 | | /// <summary> |
| | 6 | | /// The SkiaSharp extensions. |
| | 7 | | /// </summary> |
| | 8 | | public static class SkiaExtensions |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Draws an SKBitmap on the canvas with specified SkSamplingOptions. |
| | 12 | | /// </summary> |
| | 13 | | /// <param name="canvas">The SKCanvas to draw on.</param> |
| | 14 | | /// <param name="bitmap">The SKBitmap to draw.</param> |
| | 15 | | /// <param name="dest">The destination SKRect.</param> |
| | 16 | | /// <param name="options">The SKSamplingOptions to use for rendering.</param> |
| | 17 | | /// <param name="paint">Optional SKPaint to apply additional effects or styles.</param> |
| | 18 | | public static void DrawBitmap(this SKCanvas canvas, SKBitmap bitmap, SKRect dest, SKSamplingOptions options, SKPaint |
| | 19 | | { |
| 0 | 20 | | using var image = SKImage.FromBitmap(bitmap); |
| 0 | 21 | | canvas.DrawImage(image, dest, options, paint); |
| 0 | 22 | | } |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Draws an SKBitmap on the canvas at the specified coordinates with the given SkSamplingOptions. |
| | 26 | | /// </summary> |
| | 27 | | /// <param name="canvas">The SKCanvas to draw on.</param> |
| | 28 | | /// <param name="bitmap">The SKBitmap to draw.</param> |
| | 29 | | /// <param name="x">The x-coordinate where the bitmap will be drawn.</param> |
| | 30 | | /// <param name="y">The y-coordinate where the bitmap will be drawn.</param> |
| | 31 | | /// <param name="options">The SKSamplingOptions to use for rendering.</param> |
| | 32 | | /// <param name="paint">Optional SKPaint to apply additional effects or styles.</param> |
| | 33 | | public static void DrawBitmap(this SKCanvas canvas, SKBitmap bitmap, float x, float y, SKSamplingOptions options, SK |
| | 34 | | { |
| 0 | 35 | | using var image = SKImage.FromBitmap(bitmap); |
| 0 | 36 | | canvas.DrawImage(image, x, y, options, paint); |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Draws an SKBitmap on the canvas using a specified source rectangle, destination rectangle, |
| | 41 | | /// and optional paint, with the given SkSamplingOptions. |
| | 42 | | /// </summary> |
| | 43 | | /// <param name="canvas">The SKCanvas to draw on.</param> |
| | 44 | | /// <param name="bitmap">The SKBitmap to draw.</param> |
| | 45 | | /// <param name="source"> |
| | 46 | | /// The source SKRect defining the portion of the bitmap to draw. |
| | 47 | | /// </param> |
| | 48 | | /// <param name="dest"> |
| | 49 | | /// The destination SKRect defining the area on the canvas where the bitmap will be drawn. |
| | 50 | | /// </param> |
| | 51 | | /// <param name="options">The SKSamplingOptions to use for rendering.</param> |
| | 52 | | /// <param name="paint">Optional SKPaint to apply additional effects or styles.</param> |
| | 53 | | public static void DrawBitmap(this SKCanvas canvas, SKBitmap bitmap, SKRect source, SKRect dest, SKSamplingOptions o |
| | 54 | | { |
| 0 | 55 | | using var image = SKImage.FromBitmap(bitmap); |
| 0 | 56 | | canvas.DrawImage(image, source, dest, options, paint); |
| 0 | 57 | | } |
| | 58 | | } |