summaryrefslogtreecommitdiff
path: root/test/svg2png.c
diff options
context:
space:
mode:
authorEmmanuel Pacaud <emmanuel.pacaud@free.fr>2005-12-19 13:59:34 +0000
committerEmmanuel Pacaud <emmanuel.pacaud@free.fr>2005-12-19 13:59:34 +0000
commitec574cd6f0a4244a45d69894f41db1910585e05d (patch)
tree9039a57099a50ccd9a774914526ebf2dab25278a /test/svg2png.c
parent70c45dd5020af78ee2532ceb8d55eea619bc4aaa (diff)
downloadcairo-ec574cd6f0a4244a45d69894f41db1910585e05d.tar.gz
CAIRO_CAN_TEST_SVG_SURFACE depends on librsvg.
cairo_svg_surface_t owns a xml node, for support of svg_surface_composite. (_cairo_svg_surface_create_for_document): init xml_node. All surfaces except first one are stored in defs node. (emit_composite_image_pattern): returns pattern size, and don't call emit_transform if is_pattern == TRUE. (emit_composite_svg_pattern): do something. (emit_composite_pattern): returns pattern size. (_cairo_svg_surface_composite): xml_node is stored in cairo_svg_surface_t now. (emit_surface_pattern): emit surface pattern width here. Fix property names. (_cairo_svg_path_close_path): don't close path if no current point. (_cairo_svg_surface_fill_rectangles): new. (_cairo_svg_surface_fill): emit fill rule. xml_node is in surface now. (_cairo_svg_surface_composite_trapezoids): xml_node is in surface now. (_cairo_svg_surface_stroke): ditto. (_cairo_svg_surface_intersect_clip_path): ditto. Emit fill rule. ignore svg2png. build svg2png utility. test SVG backend if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE. new.
Diffstat (limited to 'test/svg2png.c')
-rw-r--r--test/svg2png.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/svg2png.c b/test/svg2png.c
new file mode 100644
index 000000000..bcbc3bb58
--- /dev/null
+++ b/test/svg2png.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ * Copyright © 2005 Emmanuel Pacaud <emmanuel.pacaud@free.fr>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Kristian Høgsberg <krh@redhat.com>
+ * Emmanuel Pacaud <emmanuel.pacaud@free.fr>
+ */
+
+#include <stdlib.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkpixbuf.h>
+#include <librsvg/rsvg.h>
+
+#define FAIL(msg) \
+ do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0)
+
+#define PIXELS_PER_POINT 1
+
+int main (int argc, char *argv[])
+{
+ GError *error = NULL;
+ GdkPixbuf *pixbuf;
+ const char *filename = argv[1];
+ const char *output_filename = argv[2];
+
+ if (argc != 3)
+ FAIL ("usage: svg2png input_file.svg output_file.png");
+
+ g_type_init ();
+
+ error = NULL;
+
+ pixbuf = rsvg_pixbuf_from_file (filename, &error);
+ if (error != NULL)
+ FAIL (error->message);
+
+ gdk_pixbuf_save (pixbuf, output_filename, "png", &error, NULL);
+ if (error != NULL)
+ FAIL (error->message);
+
+ g_object_unref (pixbuf);
+ return 0;
+}