[18351] | 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- |
---|
[17276] | 2 | |
---|
| 3 | test-rsvg.c: Command line utility for exercising rsvg. |
---|
| 4 | |
---|
| 5 | Copyright (C) 2000 Eazel, Inc. |
---|
| 6 | |
---|
| 7 | This program is free software; you can redistribute it and/or |
---|
[18274] | 8 | modify it under the terms of the GNU Library General Public License as |
---|
[17276] | 9 | published by the Free Software Foundation; either version 2 of the |
---|
| 10 | License, or (at your option) any later version. |
---|
| 11 | |
---|
| 12 | This program is distributed in the hope that it will be useful, |
---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
[18274] | 15 | Library General Public License for more details. |
---|
[17276] | 16 | |
---|
[18274] | 17 | You should have received a copy of the GNU Library General Public |
---|
[17276] | 18 | License along with this program; if not, write to the |
---|
| 19 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
| 20 | Boston, MA 02111-1307, USA. |
---|
| 21 | |
---|
| 22 | Author: Raph Levien <raph@artofcode.com> |
---|
| 23 | */ |
---|
| 24 | |
---|
[18274] | 25 | #include "config.h" |
---|
| 26 | #include "rsvg.h" |
---|
| 27 | |
---|
| 28 | #include <popt.h> |
---|
[17276] | 29 | #include <stdio.h> |
---|
| 30 | #include <stdlib.h> |
---|
| 31 | |
---|
[18274] | 32 | int |
---|
| 33 | main (int argc, const char **argv) |
---|
[17276] | 34 | { |
---|
[18274] | 35 | poptContext popt_context; |
---|
[18351] | 36 | char *x_zoom_str = "1.0"; |
---|
| 37 | char *y_zoom_str = "1.0"; |
---|
[18274] | 38 | struct poptOption options_table[] = { |
---|
[18351] | 39 | { "x-zoom", 'x', POPT_ARG_STRING, &x_zoom_str, 0, NULL, "zoom factor" }, |
---|
| 40 | { "y-zoom", 'y', POPT_ARG_STRING, &y_zoom_str, 0, NULL, "zoom factor" }, |
---|
[18274] | 41 | POPT_AUTOHELP |
---|
[18351] | 42 | { NULL, 0, 0, NULL, 0 } |
---|
[18274] | 43 | }; |
---|
[18351] | 44 | char c; |
---|
[18274] | 45 | const char * const *args; |
---|
| 46 | GdkPixbuf *pixbuf; |
---|
[17276] | 47 | |
---|
[18351] | 48 | g_type_init (); |
---|
[17276] | 49 | |
---|
[18351] | 50 | popt_context = poptGetContext ("test-rsvg", argc, argv, options_table, 0); |
---|
| 51 | |
---|
[18274] | 52 | c = poptGetNextOpt (popt_context); |
---|
| 53 | args = poptGetArgs (popt_context); |
---|
[17276] | 54 | |
---|
[18351] | 55 | pixbuf = rsvg_pixbuf_from_file_at_zoom (args[0], |
---|
| 56 | atof (x_zoom_str), |
---|
| 57 | atof (y_zoom_str), |
---|
| 58 | NULL); |
---|
| 59 | if (pixbuf) { |
---|
| 60 | if (args[1] != NULL) |
---|
| 61 | gdk_pixbuf_save (pixbuf, args[1], "png", NULL, NULL); |
---|
| 62 | } else { |
---|
[18274] | 63 | fprintf (stderr, "Error loading SVG file.\n"); |
---|
| 64 | return 1; |
---|
[17276] | 65 | } |
---|
| 66 | return 0; |
---|
| 67 | } |
---|