Commit 44d889f7 authored by Dom Lachowicz's avatar Dom Lachowicz

Fix error that was hurting nautilus icon themes

	* rsvg.c (start_svg): Fix error that was hurting nautilus icon themes

	* test-rsvg.c (main): fix segfaults, add width, height arguments, configurable output format
parent 0205e78e
2002-10-03 Dom Lachowicz <doml@appligent.com>
* rsvg.c (start_svg): Fix error that was hurting nautilus icon themes
* test-rsvg.c (main): fix segfaults, add width, height arguments, configurable output format
2002-10-03 Matthias Clasen <maclas@gmx.de>
* gdk-pixbuf-loader : RSVG can now be optionally a loadable module for GdkPixbuf, if you have a new enough version of GdkPixbuf
......
......@@ -257,7 +257,7 @@ rsvg_start_svg (RsvgHandle *ctx, const xmlChar **atts)
to acquire our real destination size. we'll scale it against
the viewBox's coordinates later */
if (ctx->size_func)
(* ctx->size_func) (&height, &height, ctx->user_data);
(* ctx->size_func) (&width, &height, ctx->user_data);
}
else
{
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
test-rsvg.c: Command line utility for exercising rsvg.
Copyright (C) 2000 Eazel, Inc.
Copyright (C) 2002 Dom Lachowicz
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
......@@ -28,21 +29,30 @@
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main (int argc, const char **argv)
{
poptContext popt_context;
char *x_zoom_str = "1.0";
char *y_zoom_str = "1.0";
double x_zoom = 1.0;
double y_zoom = 1.0;
gint width = -1;
gint height = -1;
char * format = "png";
struct poptOption options_table[] = {
{ "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" },
{ "x-zoom", 'x', POPT_ARG_DOUBLE, &x_zoom, 0, NULL, "x zoom factor" },
{ "y-zoom", 'y', POPT_ARG_DOUBLE, &y_zoom, 0, NULL, "y zoom factor" },
{ "width", 'w', POPT_ARG_INT, &width, 0, NULL, "width" },
{ "height", 'h', POPT_ARG_INT, &height, 0, NULL, "height" },
{ "format", 'f', POPT_ARG_STRING, &format, 0, NULL, "save format [png, jpeg]" },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0 }
{ NULL, 0, 0, NULL, 0, NULL, NULL }
};
char c;
int c;
const char * const *args;
gint n_args = 0;
GdkPixbuf *pixbuf;
g_type_init ();
......@@ -52,14 +62,37 @@ main (int argc, const char **argv)
c = poptGetNextOpt (popt_context);
args = poptGetArgs (popt_context);
pixbuf = rsvg_pixbuf_from_file_at_zoom (args[0],
atof (x_zoom_str),
atof (y_zoom_str),
NULL);
if (pixbuf) {
if (args[1] != NULL)
gdk_pixbuf_save (pixbuf, args[1], "png", NULL, NULL);
} else {
if (args)
{
while(args[n_args] != NULL)
n_args++;
}
if (n_args != 2)
{
poptPrintHelp (popt_context, stderr, 0);
return 1;
}
if (strstr (format, "jpeg") != NULL)
format = "jpeg";
else
format = "png";
/* if both are unspecified, assume user wants to zoom the pixbuf in at least 1 dimension */
if (width == -1 && height == -1)
pixbuf = rsvg_pixbuf_from_file_at_zoom (args[0], x_zoom, y_zoom, NULL);
/* if both are unspecified, assume user wants to resize pixbuf in at least 1 dimension */
else if (x_zoom == 1.0 && y_zoom == 1.0)
pixbuf = rsvg_pixbuf_from_file_at_size (args[0], width, height, NULL);
else
/* assume the user wants to zoom the pixbuf, but cap the maximum size */
pixbuf = rsvg_pixbuf_from_file_at_zoom_with_max (args[0], x_zoom, y_zoom,
width, height, NULL);
if (pixbuf)
gdk_pixbuf_save (pixbuf, args[1], format, NULL, NULL);
else {
fprintf (stderr, "Error loading SVG file.\n");
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment