1 /* cairo-tutorial-png.h - a tutorial framework for cairo to write a PNG image
3 * Copyright © 2005, Carl Worth
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
20 #include <cairo-pdf.h>
36 draw (cairo_t *cr, int width, int height);
39 main (int argc, char **argv)
41 cairo_surface_t *surface;
43 char *filename, *dash;
45 filename = strdup (argv[0]);
46 assert (filename != NULL);
48 dash = strrchr (filename, '-');
50 if (strcmp (dash, "-pdf") == 0) {
54 new_filename = malloc (strlen (filename) + 5);
55 sprintf (new_filename, "%s.pdf", filename);
57 filename = new_filename;
60 surface = cairo_pdf_surface_create (filename, WIDTH, HEIGHT);
62 cr = cairo_create (surface);
64 draw (cr, WIDTH, HEIGHT);
68 cairo_surface_destroy (surface);