summaryrefslogtreecommitdiff
path: root/examples/cairosimple.c
diff options
context:
space:
mode:
authorManish Singh <yosh@gimp.org>2005-04-27 22:45:45 +0000
committerManish Singh <yosh@src.gnome.org>2005-04-27 22:45:45 +0000
commit6aee1049a38fc25f25e2ed14a6ed303cc647556a (patch)
treea794e4f1804d031f72a98379f85a1d7c8b2e9a36 /examples/cairosimple.c
parent694935328ce9f43738df9354fbdc00246481f2ed (diff)
downloadpango-6aee1049a38fc25f25e2ed14a6ed303cc647556a.tar.gz
Update to new Cairo API for writing out PNGs.
Wed Apr 27 15:45:06 2005 Manish Singh <yosh@gimp.org> * examples/cairoview.c: Update to new Cairo API for writing out PNGs.
Diffstat (limited to 'examples/cairosimple.c')
-rw-r--r--examples/cairosimple.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/cairosimple.c b/examples/cairosimple.c
index 9de60a5c..5ac00b39 100644
--- a/examples/cairosimple.c
+++ b/examples/cairosimple.c
@@ -1,6 +1,5 @@
#include <math.h>
#include <pango/pangocairo.h>
-#include <cairo-png.h>
static void
draw_text (cairo_t *cr)
@@ -57,7 +56,8 @@ draw_text (cairo_t *cr)
int main (int argc, char **argv)
{
cairo_t *cr;
- FILE *f;
+ char *filename;
+ cairo_status_t status;
if (argc != 2)
{
@@ -65,12 +65,7 @@ int main (int argc, char **argv)
return 1;
}
- f = fopen (argv[1], "wb");
- if (!f)
- {
- g_printerr ("Usage: cannot open '%s'\n", argv[1]);
- return 1;
- }
+ filename = argv[1];
cr = cairo_create();
cairo_set_target_image_no_data (cr,
@@ -82,10 +77,15 @@ int main (int argc, char **argv)
cairo_fill (cr);
draw_text (cr);
- cairo_surface_write_png (cairo_get_target_surface (cr), f);
-
+ status = cairo_surface_write_to_png (cairo_get_target_surface (cr), filename);
+
+ if (status != CAIRO_STATUS_SUCCESS)
+ {
+ g_printerr ("Could not save png to '%s'\n", filename);
+ return 1;
+ }
+
cairo_destroy (cr);
- fclose (f);
return 0;
}