[perl-Gnome2-Rsvg] Add an example for rendering to cairo



commit eeaedd4b81ccbb49d71495bed9ed19b1d9ff9921
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Tue Mar 2 23:31:28 2010 +0100

    Add an example for rendering to cairo

 MANIFEST                    |   12 +++++++-----
 examples/render-to-cairo.pl |   18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/MANIFEST b/MANIFEST
index f18c1dc..f0a4a72 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,15 +1,17 @@
 ChangeLog.pre-git
+copyright.pod
+doctypes
+examples/render-to-cairo.pl
 LICENSE
+Makefile.PL
 MANIFEST			This list of files
 MANIFEST.SKIP
-Makefile.PL
+maps
 NEWS
+perl-Gnome2-Rsvg.doap
+perl-Gnome2-Rsvg.spec.in
 README
 Rsvg.pm
-copyright.pod
-doctypes
-maps
-perl-Gnome2-Rsvg.spec.in
 rsvg.typemap
 rsvg2perl.h
 t/Rsvg.t
diff --git a/examples/render-to-cairo.pl b/examples/render-to-cairo.pl
new file mode 100644
index 0000000..f596288
--- /dev/null
+++ b/examples/render-to-cairo.pl
@@ -0,0 +1,18 @@
+use File::Basename qw(basename);
+use Gnome2::Rsvg;
+
+my $svg = $ARGV[0];
+
+my $handle = Gnome2::Rsvg::Handle -> new();
+open(SVG, $svg) or die("Opening '$svg': $!");
+while (<SVG>) {
+  $handle -> write($_) or die("Could not parse '$svg'");
+}
+close(SVG);
+$handle -> close() or die("Could not parse '$svg'");
+
+# FIXME: Use get_dimensions() once available.
+my $surface = Cairo::ImageSurface -> create("argb32", 100, 100);
+my $cr = Cairo::Context -> create($surface);
+$handle -> render_cairo($cr);
+$surface -> write_to_png(basename($svg) . '.png');



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]