blob: 7cd354f0c3faba47d6519286b72f35ef2490fed3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (c) 2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using System.IO;
using Drawing2D;
using SkiaSharp;
using Svg.Skia;
namespace Crow.SkiaBackend
{
public sealed class SvgHandle : ISvgHandle {
SKSvg handle;
SvgHandle () {
handle = new SKSvg ();
}
internal SvgHandle (string file_name) : this ()
{
handle.Load (file_name);
}
internal SvgHandle (Stream stream) : this ()
{
handle.Load (stream);
}
internal static SvgHandle FromFragment (string framgment) {
SvgHandle svg = new SvgHandle();
svg.handle.FromSvg (framgment);
return svg;
}
public void Render(IContext cr)
{
Context ctx = cr as Context;
ctx.canvas.DrawPicture (handle.Picture);
}
public void Render (IContext cr, string id)
{
Context ctx = cr as Context;
ctx.canvas.DrawPicture (handle.Picture);
}
public Size Dimensions
=> new Size ((int)handle.Drawable.Bounds.Width, (int)handle.Drawable.Bounds.Height);
public void Dispose() {
handle.Dispose ();
}
}
}
|