some updates
[iv.d.git] / librsvg.d
blob86090d46a8343c8e340343d6f745cb5f4fd83336
1 /*
2 rsvg.h: SAX-based renderer for SVG files into a GdkPixbuf.
4 Copyright (C) 2000 Eazel, Inc.
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with this program; if not, write to the
18 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
21 Author: Raph Levien <raph@artofcode.com>
23 module iv.librsvg /*is aliced*/;
24 pragma(lib, "rsvg-2");
25 pragma(lib, "gio-2.0");
26 pragma(lib, "gdk_pixbuf-2.0");
27 pragma(lib, "gobject-2.0");
28 pragma(lib, "glib-2.0");
30 import iv.alice;
31 import iv.cairo;
33 extern(C) nothrow @nogc:
35 alias rsvgbool = int;
36 struct GError;
38 void g_error_free (GError* err);
41 enum LIBRSVG_MAJOR_VERSION = 2;
42 enum LIBRSVG_MINOR_VERSION = 40;
43 enum LIBRSVG_MICRO_VERSION = 16;
44 enum LIBRSVG_VERSION = "2.40.16";
46 bool LIBRSVG_CHECK_VERSION (int major, int minor, int micro) pure nothrow @safe @nogc {
47 pragma(inline, true);
48 return
49 (LIBRSVG_MAJOR_VERSION > major ||
50 (LIBRSVG_MAJOR_VERSION == major && LIBRSVG_MINOR_VERSION > minor) ||
51 (LIBRSVG_MAJOR_VERSION == major && LIBRSVG_MINOR_VERSION == minor && LIBRSVG_MICRO_VERSION >= micro));
54 extern immutable uint librsvg_major_version;
55 extern immutable uint librsvg_minor_version;
56 extern immutable uint librsvg_micro_version;
57 extern immutable(char)* librsvg_version;
59 /**
60 * RsvgError:
61 * @RSVG_ERROR_FAILED: the request failed
63 * An enumeration representing possible errors
65 alias RsvgError = int;
66 enum : RsvgError {
67 RSVG_ERROR_FAILED
70 /**
71 * RsvgHandle:
73 * The #RsvgHandle is an object representing the parsed form of a SVG
75 struct RsvgHandle;
76 struct RsvgHandlePrivate;
77 struct RsvgHandleClass;
79 /**
80 * RsvgDimensionData:
81 * @width: SVG's width, in pixels
82 * @height: SVG's height, in pixels
83 * @em: em
84 * @ex: ex
86 struct RsvgDimensionData {
87 int width;
88 int height;
89 double em;
90 double ex;
93 /**
94 * RsvgPositionData:
95 * @x: position on the x axis
96 * @y: position on the y axis
98 * Position of an SVG fragment.
100 struct RsvgPositionData {
101 int x;
102 int y;
105 void rsvg_cleanup ();
107 void rsvg_set_default_dpi (double dpi);
108 void rsvg_set_default_dpi_x_y (double dpi_x, double dpi_y);
110 void rsvg_handle_set_dpi (RsvgHandle* handle, double dpi);
111 void rsvg_handle_set_dpi_x_y (RsvgHandle* handle, double dpi_x, double dpi_y);
113 RsvgHandle* rsvg_handle_new ();
114 rsvgbool rsvg_handle_write (RsvgHandle* handle, const(void)* buf, usize count, GError** error);
115 rsvgbool rsvg_handle_close (RsvgHandle* handle, GError** error);
117 GdkPixbuf* rsvg_handle_get_pixbuf (RsvgHandle* handle);
118 GdkPixbuf* rsvg_handle_get_pixbuf_sub (RsvgHandle* handle, const char *id);
121 const(char)* rsvg_handle_get_base_uri (RsvgHandle* handle);
122 void rsvg_handle_set_base_uri (RsvgHandle* handle, const(char)* base_uri);
124 void rsvg_handle_get_dimensions (RsvgHandle* handle, RsvgDimensionData* dimension_data);
126 rsvgbool rsvg_handle_get_dimensions_sub (RsvgHandle* handle, RsvgDimensionData* dimension_data, const(char)* id);
127 rsvgbool rsvg_handle_get_position_sub (RsvgHandle* handle, RsvgPositionData* position_data, const(char)* id);
129 rsvgbool rsvg_handle_has_sub (RsvgHandle* handle, const(char)* id);
131 /* GIO APIs */
134 * RsvgHandleFlags:
135 * @RSVG_HANDLE_FLAGS_NONE: none
136 * @RSVG_HANDLE_FLAG_UNLIMITED: Allow any SVG XML without size limitations.
137 * For security reasons, this should only be used for trusted input!
138 * Since: 2.40.3
139 * @RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA: Keeps the image data when loading images,
140 * for use by cairo when painting to e.g. a PDF surface. This will make the
141 * resulting PDF file smaller and faster.
142 * Since: 2.40.3
144 /*< flags >*/
146 alias RsvgHandleFlags = int;
147 enum : RsvgHandleFlags {
148 RSVG_HANDLE_FLAGS_NONE = 0,
149 RSVG_HANDLE_FLAG_UNLIMITED = 1 << 0,
150 RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA = 1 << 1
154 //RsvgHandle* rsvg_handle_new_with_flags (RsvgHandleFlags flags);
155 //void rsvg_handle_set_base_gfile (RsvgHandle* handle, GFile* base_file);
156 //rsvgbool rsvg_handle_read_stream_sync (RsvgHandle* handle, GInputStream* stream, GCancellable* cancellable, GError** error);
157 //RsvgHandle* rsvg_handle_new_from_gfile_sync (GFile* file, RsvgHandleFlags flags, GCancellable* cancellable, GError** error);
158 //RsvgHandle *rsvg_handle_new_from_stream_sync (GInputStream* input_stream, GFile* base_file, RsvgHandleFlags flags, GCancellable* cancellable, GError** error);
160 RsvgHandle* rsvg_handle_new_from_data (const(void)* data, usize data_len, GError** error);
161 RsvgHandle* rsvg_handle_new_from_file (const(char)* file_name, GError** error);
164 rsvgbool rsvg_handle_render_cairo (RsvgHandle* handle, cairo_t* cr);
165 rsvgbool rsvg_handle_render_cairo_sub (RsvgHandle* handle, cairo_t* cr, const(char)* id);