[cairo-commit] svg2png/src args.c,1.3,1.4 svg2png.c,1.6,1.7

Carl Worth commit at pdx.freedesktop.org
Tue Apr 26 13:03:35 PDT 2005


Committed by: cworth

Update of /cvs/cairo/svg2png/src
In directory gabe:/tmp/cvs-serv9076/src

Modified Files:
	args.c svg2png.c 
Log Message:

        * Makefile.am: Remove extra whitespace.

        * src/args.c: (args_help): Make usage statement more clear.

        * src/svg2png.c: (write_callback), (write_surface_to_png_file),
        (render_to_png): Track changes in cairo PNG output interface. Use
        new cairo_surface_write_to_png_stream in place of old
        cairo_surface_write_png.


Index: args.c
===================================================================
RCS file: /cvs/cairo/svg2png/src/args.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- args.c	11 Jun 2004 12:49:59 -0000	1.3
+++ args.c	26 Apr 2005 20:03:33 -0000	1.4
@@ -68,7 +68,7 @@
     char *argv0_copy = strdup (argv0);
     char *argv0_base = basename (argv0_copy);
 
-    printf ("Usage: %s [OPTION] %s\n", argv0_base, ARGS_PROGRAM_ARGDOC);
+    printf ("Usage: %s [OPTIONS] %s\n", argv0_base, ARGS_PROGRAM_ARGDOC);
     printf ("%s - %s\n", argv0_base, ARGS_PROGRAM_DESCRIPTION);
     puts ("");
     printf ("  -w, --width=WIDTH\tWidth of output image in pixels\n");

Index: svg2png.c
===================================================================
RCS file: /cvs/cairo/svg2png/src/svg2png.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- svg2png.c	2 Apr 2005 02:01:31 -0000	1.6
+++ svg2png.c	26 Apr 2005 20:03:33 -0000	1.7
@@ -87,10 +87,37 @@
     return 0;
 }
 
+static cairo_status_t
+write_callback (void *closure, const unsigned char *data, unsigned int length)
+{
+    size_t written;
+    FILE *file = closure;
+
+    written = fwrite (data, 1, length, file);
+
+    if (written == length)
+	return CAIRO_STATUS_SUCCESS;
+    else
+	return CAIRO_STATUS_WRITE_ERROR;
+}
+
+static svg_cairo_status_t
+write_surface_to_png_file (cairo_surface_t *surface, FILE *file)
+{
+    cairo_status_t status;
+
+    status = cairo_surface_write_to_png_stream (surface, write_callback, file);
+
+    if (status)
+	return SVG_CAIRO_STATUS_IO_ERROR;
+    else
+	return SVG_CAIRO_STATUS_SUCCESS;
+}
+
 static svg_cairo_status_t
 render_to_png (FILE *svg_file, FILE *png_file, double scale, int width, int height)
 {
-    int svg_width, svg_height;
+    unsigned int svg_width, svg_height;
 
     svg_cairo_status_t status;
     cairo_t *cr;
@@ -135,13 +162,15 @@
     /* XXX: This probably doesn't need to be here (eventually) */
     cairo_set_rgb_color (cr, 1, 1, 1);
 
-    svg_cairo_render (svgc, cr);
+    status = svg_cairo_render (svgc, cr);
 
-    cairo_surface_write_png (cairo_get_target_surface (cr), png_file);
+    status = write_surface_to_png_file (cairo_get_target_surface (cr), png_file);
+    if (status)
+	return status;
 
     svg_cairo_destroy (svgc);
 
     cairo_destroy (cr);
 
-    return SVG_CAIRO_STATUS_SUCCESS;
+    return status;
 }




More information about the cairo-commit mailing list