Loading a SVG file and displaying it on SDL

André Wagner <[email protected]>
Newsgroups gmane.comp.gnome.lib.librsvg.devel
Message-ID <[email protected]>
Hello!

I'm trying to load a SVG file and show it in a SDL window using cairo. This is my code:

	RsvgHandle* h;
	int width = 500;
	int height = 500;
	int stride = width * 4;

	unsigned char* cairo_data = 
		(unsigned char *) calloc(stride * height, 1);
	cairo_surface_t *cairo_surface =
		cairo_image_surface_create_for_data(cairo_data,
				CAIRO_FORMAT_ARGB32, width,
				height, stride);

	cairo_t *cr = cairo_create(cairo_surface);
	cairo_save(cr);
	cairo_scale(cr, width, height);

	cairo_set_source_rgba(cr, 1, 1, 1, 1);
	cairo_paint(cr);

	GError* e = NULL;
	h = rsvg_handle_new_from_file("closedbox.svg", &e);
	if(e != NULL)
		exit(1);

	rsvg_handle_render_cairo(h, cr);

	SDL_Surface* sf;
	sf = SDL_CreateRGBSurfaceFrom((void *) cairo_data, width, 
			height, 32, stride, 0x00ff0000, 0x0000ff00, 
                        0x000000ff, 0xff000000);

	SDL_BlitSurface(sf, NULL, screen, NULL);
	SDL_UpdateRect(screen, 0, 0, 0, 0);

	cairo_destroy(cr);

What am I doing wrong? It displays a white window, so I know (suppose) the transference from cairo to SDL is working. It seems the SVG image I loaded using librsvga is not showing on my cairo surface.

I'm not very skilled with cairo or librsvga, so I might just have a stupid mistake.

I'm using Win32, BTW (I hope this isn't the stupid mistke ;-)

Best regards,

André

-- 
A cura para o tédio é a curiosidade.
Não há cura para a curiosidade. (Dorothy Parker)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.