[cairo] Examples of raster output

Alexander Shulgin alex.shulgin at gmail.com
Thu Mar 11 23:05:49 PST 2010

On Fri, Mar 12, 2010 at 01:31, Stephan Siemen <Stephan.Siemen at ecmwf.int> wrote:
> Hi,
> being a happy user of the vector outputs Cairo generates, I am looking now
> to generate (optimised) raster outputs, such as GIF, JPEG, but especially
> PNG. Conversion programs, such as Imagemagick convert, take much too long.
> I wondered if there is any documentation/examples out there using libpng and
> libgif from Cairo outputs? Are there ways to easily extend the png output
> from Cairo to 8bit colour depth?

The easiest way would be to use PNG support functions built into cairo.

However, if you're interested in GIF or JPEG, you may want to take a
look at libgdiplus sources here:

Look for {gif,jpeg,png}codec.c files.  Caution: pngcodec's saving
function is missing de-multiplication of R,G,B channels for the case
of ARGB32 cairo format, you'll need to add this yourself if you decide
to use that code.

I don't think I understand your question about 8bit color depth.  Can
you rephrase it please?  Are you talking about quantizing 24-bit RGB
image into 8-bit indexed colors?


More information about the cairo mailing list