[Cairo] PNG backend for cairo?

David Morse svref at yahoo.com
Fri Nov 14 16:01:53 PST 2003

./configure --with-png=yes ?

Abraham Egnor wrote:
> I'd prefer that it be in its own library, less because of dependencies
> than because it keeps the interface clean.  I suspect that confusion is a
> non-issue; potential cairo users will be smart enough to read
> documentation, I'm pretty sure.  Keeping backends that don't require
> internal functionality in separate libraries also scales much better.
> Abe
> Carl Worth <cworth at east.isi.edu> writes:
>>As most of you know, I rarely use cairo for more than trivially simple
>>demonstrations. But, since I'm getting pretty good at those, I'm
>>tempted to make them even more trivial.
>>In order to do so, I'm tempted to add a PNG backend to cairo. (I
>>actually think this would be helpful beyond the case of trivial demos,
>>but I can't prove that since I almost never write those kinds of
>>The problem with adding a PNG backend is that it would introduce a new
>>dependency, (on libpng), and of course I'd like to minimize
>>One option is to introduce a new helper library libcairo-png or some
>>such with its own <cairo-png.h>. This is possible since the PNG
>>backend only requires functionality already in the public API. This is
>>in contrast to the X/Render backend or a potential PDF backend, which
>>require internal functionality.
>>But I don't like the notion of confusing the user with respect to
>>which backends are builtin and which are available only in helper
>>So, I'm back to wanting to shove the PNG backend directly into
>>cairo. While some might see the libpng dependency as gratuitous, some
>>might already find the X library dependencies equally (or more)
>>gratuitous. So maybe all we need is the ability to optionally disable
>>backends at compile time?
>>Any thoughts to help me out?
>>PS. Here's a fairly minimal, but complete example possible with the
>>proposed PNG backend. The differences compared to what's possible
>>today is that there's no need to allocate an image buffer, worry about
>>stride, or write code to convert the image and write it out as a PNG.
>>#include <cairo.h>
>>int main (void)
>>   cairo_t *cr;
>>   cr = cairo_create ();
>>   cairo_set_target_png (cr, "demo.png", CAIRO_FORMAT_ARGB32, 100, 100);
>>   cairo_move_to (cr, 10., 10.);
>>   cairo_line_to (cr, 90., 90.);
>>   cairo_set_rgb_color (cr, 0., 0., 1.);
>>   cairo_fill (cr);
>>   cairo_destroy (cr);
>>   return 0;

More information about the cairo mailing list