Loaded JPGs transfered to cairo with gdk_cairo_set_source_pixbuf() don't use cairo_surface_set_mime_data()
Submitted by Andrew Cowie
When using ImageSurfaces implicily creating a Cairo Surface with gdk_cairo_set_source_pixbuf(). Cairo will draw the image as a bitmap.
This is sub-optimal for when drawing out to a vector backend like PDF, SVG, PS, etc [ie, when printing] - you end up with huge multi megabyte files where the origin JPEG was only a few hundred kilobytes. Bummer.
As of Cairo 1.10 there's now cairo_surface_set_mime_data() where the original encoded image data can be attached to the surface being drawn, and, if the output turns out to be a vector backend the mime data is used instead of the fallback bitmap.
In our case, that means:
// use data to create GdkPixbuf gdk_pixbuf_new_from_... gdk_cairo_set_source_pixbuf() // extract the implicitly created surface cairo_pattern_get_surface() // use the original data here as the anti-fallback :) cairo_surface_set_mime_data() // continue, drawing image onto target. cairo_paint()
Adrian Johnson suggested that maybe the
gdk_cairo_set_source_pixbuf() could just do the
cairo_surface_set_mime_data() call automatically.
I'm not sure if we still have the originally loaded from disk etc image still attached to the GdkPixbuf, but if we do this would be easy. If not, seems like it would be something to think about seeing as we are now drawing exclusively with Cairo, all in the "give Cairo more information" department.
Wasn't really clear whether this should go here or against gdk-pixbuf in Bugzilla.