Tizen 2.0 Release
[framework/graphics/cairo.git] / test / svg2png.c
1 /*
2  * Copyright © 2005 Red Hat, Inc.
3  * Copyright © 2005 Emmanuel Pacaud <emmanuel.pacaud@free.fr>
4  *
5  * Permission to use, copy, modify, distribute, and sell this software
6  * and its documentation for any purpose is hereby granted without
7  * fee, provided that the above copyright notice appear in all copies
8  * and that both that copyright notice and this permission notice
9  * appear in supporting documentation, and that the name of
10  * Red Hat, Inc. not be used in advertising or publicity pertaining to
11  * distribution of the software without specific, written prior
12  * permission. Red Hat, Inc. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as
14  * is" without express or implied warranty.
15  *
16  * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18  * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
19  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
20  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
22  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23  *
24  * Author: Kristian Høgsberg <krh@redhat.com>
25  *         Emmanuel Pacaud <emmanuel.pacaud@free.fr>
26  */
27
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <gdk/gdk.h>
31 #include <gdk/gdkpixbuf.h>
32 #include <librsvg/rsvg.h>
33
34 #define FAIL(msg)                                                       \
35     do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0)
36
37 int main (int argc, char *argv[])
38 {
39     GError *error = NULL;
40     GdkPixbuf *pixbuf;
41     const char *filename = argv[1];
42     const char *output_filename = argv[2];
43
44     if (argc != 3)
45         FAIL ("usage: svg2png input_file.svg output_file.png");
46
47     g_type_init ();
48
49     error = NULL;
50
51     rsvg_set_default_dpi (72.0);
52     pixbuf = rsvg_pixbuf_from_file (filename, &error);
53     if (error != NULL)
54         FAIL (error->message);
55
56     gdk_pixbuf_save (pixbuf, output_filename, "png", &error, NULL);
57     if (error != NULL)
58         FAIL (error->message);
59
60     g_object_unref (pixbuf);
61     return 0;
62 }