summaryrefslogtreecommitdiff
path: root/plugins/SvgCairo.cs
blob: 5981538e918b35fb658ba573e1bb3d09ef78e507 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Runtime.InteropServices;
using Cairo;

namespace NDesk.Graphics
{
	public class Svg
	{
		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_create (out IntPtr svg_cairo);

		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_destroy (out IntPtr svg_cairo);

		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_parse (IntPtr svg_cairo, string filename);

		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_parse_file (IntPtr svg_cairo, IntPtr file);

		//TODO: verify
		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_parse_buffer (IntPtr svg_cairo, byte[] buf, uint count);

		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_parse_chunk_begin (IntPtr svg_cairo);

		//TODO: verify
		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_parse_chunk (IntPtr svg_cairo, byte[] buf, uint count);

		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_parse_chunk_end (IntPtr svg_cairo);

		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_render (IntPtr svg_cairo, IntPtr xrs);

		[DllImport("svg-cairo")]
			protected static extern IntPtr svg_cairo_set_viewport_dimension (IntPtr svg_cairo, uint width, uint height);

		[DllImport("svg-cairo")]
			protected static extern void svg_cairo_get_size (IntPtr svg_cairo, out uint width, out uint height);

		protected IntPtr Handle;

		public Svg ()
		{
			svg_cairo_create (out Handle);
		}

		public void Render (Cairo.Context xrs)
		{
			svg_cairo_render (Handle, xrs.Handle);
		}

		public void Parse (string filename)
		{
			svg_cairo_parse (Handle, filename);
		}

		public void SetViewportDimension (uint width, uint height)
		{
			svg_cairo_set_viewport_dimension (Handle, width, height);
		}

		public void GetSize (out uint width, out uint height)
		{
			svg_cairo_get_size (Handle, out width, out height);
		}
	}

	/* The returned status; not used yet:

	protected enum Status
	{
		Success,
			NoMemory,
			IOError,
			FileNotFound,
			InvalidValue,
			InvalidCall,
			ParseError,
	}
	*/
}