[cairo] RGB16_565 - a diff that fixes png writing.

David Hill David.Hill at Sun.COM
Fri May 18 13:25:40 PDT 2007

In my quest to restore 565....

I have a diff attached that shows my current proposed changes to the 
tree. They restore CAIRO_FORMAT_RGB16_565 to cairo.h and remove it from 

The rest of the diff is some corrections for cairo-image-surface.c and 
then the changes needed in cairo-png.c to support writing a png from a 
565 surface. I ran the tests and got the same 13 failures I had before I 
started changing things.

Questions and issues....

0) It occurred to me that 565 should be conditionally supported. There 
are only a few places in Cairo that would need an #ifdef to make that 
happen. But then it would have to be added to configure....

1) What to do about the Xlib support. I am not sure what to do here, 
(nor is it my primary platform). To me, I don't see any reason to 
support it, but then again, I don't have easy access to a Linux port on 
a PDA that may have a 565 visual. Even if X has a visual that does 
support it, you would need a query for that visual and code to check 
against the users requested surface type.  I think it is reasonable to 
have the Xlib backend not support CAIRO_FORMAT_RGB16_565, much the same 
way as the other backends only support selective surfaces. I just an not 
sure how to code this in a manner that the people that care about the 
xlib backend are going to accept. If left up to me, I would put in an 
assert which is what some of the other backends do.

2) #define CAIRO_FORMAT_VALID(format) ((format) <= CAIRO_FORMAT_RGB16_565)

This macro is currently only used in cairo-image-surface.c & 
cairo-xlib-surface.c. Given what I said above, perhaps this macro needs 
to be backend sensitive ?

3) Testing, I tested the png support with a hackup program (mytest.c 
attached). If you tweak the app, it will create surfaces for 565, RGB 
and ARGB and all of them produced valid  png files. What other paths are 
needed here.

So... what else guys ?

Dave Hill
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pngdiff.txt
Url: http://cairographics.org/archives/cairo/attachments/20070518/10ec5796/attachment-0001.txt 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mytest.c
Type: text/x-csrc
Size: 2015 bytes
Desc: not available
Url : http://cairographics.org/archives/cairo/attachments/20070518/10ec5796/attachment-0001.c 

More information about the cairo mailing list