[cairo] Embedding jpeg in pdf

Jeremy Lea reg at FreeBSD.org
Mon Jul 14 13:22:01 PDT 2008


Hi,

On Sun, Jul 13, 2008 at 01:53:50PM +0930, Adrian Johnson wrote:
> There are a couple of ways this could be implemented.

Please also consider a rendering callback aproach.  Allow cairo API
consumers to register a function (either at a global level or per cairo
surface?), which follows a signuture something like this:

cairo_status_t
cairo_rendering_callback(cairo_surface_t *surface,
                         cairo_surface_type_t type,
                         cairo_surface_type_render_t render);

where the the render type would be a union of types containing the raw
surface information (PDF/PS stream, XPixmap, GDI stuff, etc.), which the
callback can use.  If the callback knows how to render this surface to
the specified backend, then it does it and returns success, else it
returns unsupported, and cairo falls back to rendering it as it does
now. Cairo should have already set the transforms and clips etc.

This means cairo knows nothing about image types, and allows a consumer
to add support for any additional types (like PDF or PS passthrough). 
The consumer could set any pointers it needs as private data on the
surface, without any ownership problems, and giving the consumer freedom
to implement things in different ways (for example, keeping the filename
of the jpeg and mostly copying it, without having both encoded and
decoded versions in memory).

This would duplicate code in consumers, but if there was an example
function in the test suite, then people could copy that.  One day, it
will be in a cario image support library which someone writes ;-)

Regards,
  -Jeremy

-- 
FreeBSD - Because the best things in life are free...
                                           http://www.freebsd.org/


More information about the cairo mailing list