Re: librsvg api



2009/4/17 Stefan Kost <ensonic hora-obscura de>:
> hi,
>
> I am using librsvg to get pixbufs for my app. I could not find a dedicated list,
> for it, hope this one is okay.
>
> First I am using deprecated api:
>  rsvg_pixbuf_from_file_at_size
> as when using
>  rsvg_handle_get_pixbuf
> I can specify the size it should be rendered (tried rsvg_handle_set_dpi and
> rsvg_handle_set_dpi_x_y). Any idea here?
>
> I would like to use not deprecated rsvg_handle_ API, as I need to resize the
> images and I'd like to keep the svg loaded. Just set new size and rerender.

To do that, you'll need to render to a cairo surface with approperiate
scaling and convert that to pixbuf. You can get the "natural" pixel
size of the SVG with rsvg_handle_get_dimensions() to calculate the
scaling factor.

The conversion can be done by either rendering to a GdkDrawable (ie.
pixmap) and then using gdk_pixbuf_get_from_drawable() or using an
image surface and then converting the image data to the format used by
GdkPixbuf. GOffice has an example implementation of that conversion:

  http://git.gnome.org/cgit/goffice/tree/goffice/utils/go-cairo.c#n305

Personally I'd prefer the latter in the current X.Org driver
landscape; drawing a complex SVG (specially with gradients) can
seriously suck if the server needs to do lots of fallbacks to software
rendering...

> Besides some more dom exposure would be sweet.

Indeed!

> Not sure if anyone is actually even working on the lib still (which would be sad).

It seriously lacks some loving, that's for sure.

-- 
Kalle Vahlman, zuh iki fi
Powered by http://movial.com
Interesting stuff at http://sandbox.movial.com
See also http://syslog.movial.fi


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