[cairo] Converting to 8 bit black and white

Timothy Bolton ifoundthetao at gmail.com
Tue Sep 18 11:36:33 PDT 2012


Hey guys,

I have another question.  How do you convert a surface from color to 8 
bit black and white?  I've been searching and I cannot seem to find a 
way to convert a surface to black and white.

I'm pulling in images, and I need them to be black and white (not gray 
scale) for the rendering.

So, as I see it, there are a few options:
1 - Make it a requirement that the images be in the proper color when 
received.
2 - Use a different library (GD library, for instance)
3 - Figure out how to do this within Cairo

While, I would prefer to have my application do one thing, and one thing 
only (resting on option 1), I think that might be a limiting factor.

I've done this with the GD Library, however, if Cairo is capable of 
doing this, I would like to use it. I want to have as few external 
resources as possible (less updates, less moving parts, etc).

Thoughts?

I found some resources which say: "... it seems there is no easy way to 
convert a cairo surface to black and white or grayscale ..."
http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg646228.html



-- 
'We who cut mere stones must always be envisioning cathedrals.'
Quarry Worker's Creed



More information about the cairo mailing list