[cairo] Re: Embeding JPG in PDF

Baz brian.ewins at gmail.com
Fri Jan 12 14:07:33 PST 2007

[various API options discussed]

I'm not suggesting you follow it, but its worth at least looking at
the equivalent api in Quartz, CGImage:

Quartz makes a distinction between this kind of bitmap, which is
immutable and created from jpg/png/bitmap data, and the
cairo_image_surface_t equivalent (CGBitmapContext). Images are copied
unchanged into their destination if possible or rendered into a bitmap
first if they can't. The API is suggestive of some CGImages internally
having a rectangular clip (so cropped images don't require

The slippery slope doesn't appear to have happened - beyond png, jpg,
bitmap, you have to create your image outside of core graphics, and
I'd expect that those are stored internally as one of the 3 main

Something like this would need a fair bit of new API - eg a
cairo_image_t, cairo_draw_image(cr, image), plus calls to create the
images in the public side; and a per-surface-backend function to deal
with drawing the image. If the surface doesn't support the image,
cairo would fall back to rendering to cairo_image_surface, then using
this as input for set_source_surface/paint as at present.

One important point in all this is that the compressed image types are
not surfaces (ie mutable). This means cairo/quartz never deals with
compressing data, so doesn't need awkward api for compression quality

I've no opinion on adding something like this, just thought it worth
pointing at what's out there.


More information about the cairo mailing list