[cairo] Q: gtk_main() and svg_cairo_parse()

Michael N. Filippov michael at idisys.iae.nsk.su
Tue Sep 27 03:04:36 PDT 2005


Hello!

I tried to compile a very simple code (based on libsvg.cairo from 
cairo-demo/cairo_snippets, see below) with libcairo2-dev_1.0.0-3, 
libsvg-cairo1-dev_0.1.6-5 and libgtk2.0-dev_2.6.10-1 (also tried 2.8.3) 
and noticed that if gtk_main() is called before svg_cairo_parse() then 
the PNG picture looks bad (no shadows, yellow border is below the window 
etc). But if gtk_init() is called after svg_cairo_parse(), everything is 
fine. Did I miss something about API, environment variables or something 
else? Any help would be greatly appreciated.

Thanks in advance,

Michael


#include <gtk/gtk.h>
#include <svg-cairo.h>

int main(int argc, char* argv[])
{
     double  IMAGE_WIDTH	 = 256;
     double  IMAGE_HEIGHT = 256;
     cairo_surface_t*	surface = cairo_image_surface_create(
	    CAIRO_FORMAT_ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT);
     cairo_t*	cr = cairo_create(surface);
     cairo_scale(cr, IMAGE_WIDTH, IMAGE_HEIGHT);
     svg_cairo_t*    svgc;
     svg_cairo_create(&svgc);
     gtk_init(&argc, &argv);	// 1) doesn't work
     svg_cairo_parse(svgc, "data/home.svg");
//    gtk_init(&argc, &argv);	// 2) works
     unsigned	w, h;
     svg_cairo_get_size(svgc, &w, &h);
     cairo_scale(cr, 1.0 / w, 1.0 / h);
     svg_cairo_render(svgc, cr);
     svg_cairo_destroy(svgc);
     cairo_surface_write_to_png(surface, "out.png");
     cairo_destroy(cr);
     cairo_surface_destroy(surface);
     return 0;
}


More information about the cairo mailing list