}
+sub render_png
+{
+ # Martin A. Hansen, March 2010.
+
+ # Given a list of BGB tracks, render the
+ # PNG surface stream and return the base64
+ # encoded PNG data.
+
+ my ( $width, # image width
+ $height, # image height
+ $tracks, # list of BGB tracks to render
+ ) = @_;
+
+ # Returns a string.
+
+ my ( $surface, $cr, $track, $png_data );
+
+ $surface = Cairo::ImageSurface->create( 'argb32', $width, $height );
+ $cr = Cairo::Context->create( $surface );
+
+ $cr->rectangle( 0, 0, $width, $height );
+ $cr->set_source_rgb( 1, 1, 1 );
+ $cr->fill;
+
+ foreach $track ( @{ $tracks } ) {
+ draw_feature( $cr, $track ) if $track;
+ }
+
+ $png_data = base64_png( $surface );
+
+ return $png_data;
+}
+
+
+sub render_pdf_file
+{
+ # Martin A. Hansen, March 2010.
+
+ # Given a list of BGB tracks, render these and save
+ # to a PDF file.
+
+ my ( $file, # path to PDF file
+ $width, # image width
+ $height, # image height
+ $tracks, # list of BGB tracks to render
+ ) = @_;
+
+ # Returns nothing.
+
+ my ( $surface, $cr, $track );
+
+ $surface = Cairo::PdfSurface->create ( $file, $width, $height );
+ $cr = Cairo::Context->create( $surface );
+
+ $cr->rectangle( 0, 0, $width, $height );
+ $cr->set_source_rgb( 1, 1, 1 );
+ $cr->fill;
+
+ foreach $track ( @{ $tracks } ) {
+ draw_feature( $cr, $track ) if $track;
+ }
+}
+
+
+sub render_svg_file
+{
+ # Martin A. Hansen, March 2010.
+
+ # Given a list of BGB tracks, render these and save
+ # to a SVG file.
+
+ my ( $file, # path to PDF file
+ $width, # image width
+ $height, # image height
+ $tracks, # list of BGB tracks to render
+ ) = @_;
+
+ # Returns nothing.
+
+ my ( $surface, $cr, $track );
+
+ $surface = Cairo::SvgSurface->create ( $file, $width, $height );
+ $cr = Cairo::Context->create( $surface );
+
+ $cr->rectangle( 0, 0, $width, $height );
+ $cr->set_source_rgb( 1, 1, 1 );
+ $cr->fill;
+
+ foreach $track ( @{ $tracks } ) {
+ draw_feature( $cr, $track ) if $track;
+ }
+}
+
+
sub file_png
{
# Martin A. Hansen, October 2009.