test-rsvg.c 1.88 KB
Newer Older
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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-

   test-rsvg.c: Command line utility for exercising rsvg.
 
   Copyright (C) 2000 Eazel, Inc.
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.
  
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
  
   You should have received a copy of the GNU General Public
   License along with this program; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
  
   Author: Raph Levien <raph@artofcode.com>
*/

#include <stdio.h>
#include <stdlib.h>
#include <png.h>
#include <popt.h>

#include <gdk-pixbuf/gdk-pixbuf.h>

#include "rsvg.h"


int
36
main (int argc, const char **argv)
37 38
{
	GdkPixbuf *pixbuf;
39 40
	char *x_zoom_str = "1.0";
	char *y_zoom_str = "1.0";
41 42
	poptContext optCtx;
	struct poptOption optionsTable[] = {
43 44
		{ "x-zoom", 'x', POPT_ARG_STRING, &x_zoom_str, 0, NULL, "zoom factor" },
		{ "y-zoom", 'y', POPT_ARG_STRING, &y_zoom_str, 0, NULL, "zoom factor" },
45 46 47 48 49 50
		POPT_AUTOHELP
		{ NULL, 0, 0, NULL, 0 }
	};
	char c;
	const char * const *args;

Ramiro Estrugo's avatar
Ramiro Estrugo committed
51 52
	g_type_init ();

53
	optCtx = poptGetContext ("test-rsvg", argc, argv, optionsTable, 0);
54 55 56 57

	c = poptGetNextOpt (optCtx);
	args = poptGetArgs (optCtx);

58
	pixbuf = rsvg_pixbuf_from_file_at_zoom (args[0],
59 60 61
						atof (x_zoom_str),
						atof (y_zoom_str),
						NULL);
62 63 64 65
	if (pixbuf) {
		if (args[1] != NULL)
			gdk_pixbuf_save (pixbuf, args[1], "png", NULL, NULL);
	} else {
66 67 68
		fprintf (stderr, "Error loading SVG file.\n");
		return 1;
	}
69 70
	return 0;
}