[cairo] Cairo + GdkPixbuf

Benjamin Otte otte at redhat.com
Sat Jun 26 03:22:36 PDT 2010


On Sat, 2010-06-26 at 03:33 +0200, Krzysztof Kosiński wrote:
> Hello
> 
> The fact that Cairo cannot understand non-premultiplied RGBA which is
> used in GdkPixbuf is somewhat inconvenient.
> 
Yes, RGBA is the obvious choice of people new to image formats, because
it's how people think of pixels. Which is why it shows up in every
project that needs graphics but has inexperienced developers (like Gtk1,
HTML5 canvas or the PNG specification).
That alone is a good enough reason for adding support for these formats
to Cairo. I started on this work, but there are still some disagreements
on how to best support the formats' requirements (see below), so it
might take a while until my patches (or reworked versions) land in the
code repositories. But it's definitely my intention to get support for
these formats into Cairo. (Note to self: Talk to Søren about how to do
this stuff in Pixman again).

> I have some questions:
> 1. What is the amount of work necessary to add support for a new pixel
> format in the image surface?
> 2. Does supporting N pixel formats require O(N) or O(N^2) code?
>
The problem is not so much the code needed but the different
interpretation of the pixels and how to best support it. Cairo image
formats are premultiplied, GdkPixbuf is not. So you need to
multiply/divide RGB pixels by the alpha channel every time you go back
and forth.
Also, you want two new formats as GdkPixbuf is endian-independant and
Cairo is endian-dependant.

> 3. Which points made here are still valid [1]?
> 
> [1] http://live.gnome.org/GtkCairoIntegration
> 
That post is just a spat between some people and does not provide very
convincing arguments on either side. It's also very outdated. IMO it'd
be best to just delete it.

Benjamin




More information about the cairo mailing list