[cairo] Printing grayscale

Andrew Cowie andrew at operationaldynamics.com
Wed Nov 18 16:21:37 PST 2009

Where is the best place to do conversion to grayscale?

There was a nice thread in September "render in grayscale" which talked
about possible mechanisms to use Cairo to draw a coloured image as
grayscale one.

Considering the whole [application developer level] pipeline, we have:

     1. Image on disk
     2. Image loaded via gdkpixbuf
     3. Image painted via Cairo
     4. surface is a Cairo PDF surface, which we then save to disk¹
     5. load .pdf file in Evince
     6. user hits print, wherein Evince does $something and sends it
        through {CUPS before, GtkPrint nowadays?}
     7. printer (which is a very competent [if somewhat old] 1200x1220
        dpi black-and-white business class LaserJet) prints it.

So I wonder where the best place to do the colour conversion is? 

      * use something external (gimp, say) to somehow do a conversion of
        a colour source image to a second grayscale image, and push that
        through the pipeline.

Lots of control and no doubt that the image would look "good" on screen,
but very manual & difficult to repeat consistently, and not sure if I
can do a better job than some algorithm that knows about the target

      * do the conversion using the Cairo logic discussed in the "render
        in grayscale" thread and write a black and white image out to
        the PdfSurface

Tempting, if somewhat voodoo until Cairo 1.10 comes out.

      * Let Evince do the b/w conversion as it renders

Does it actually do so?

      * Let the printer do it when it receives the colour image

Which is what I think is happening now.

If letting the printer do it is the best, then fine. But I have a
suspicion that it would be better to use the bytes in file to contain a
[higher res?] {b/w, halftone, grayscale} image, rather than a full
colour one.

Anyone care to offer their opinion?


¹ PDF is our output for lots of good reasons, not the least of which is
the assumption that Evince knows more about printing than we do. It
certainly has the virtue of already existing :) Someday we could do the
GtkPrint layer ourselves, I'm sure, but we still need PDFs for passing
around to other people (to then print).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.cairographics.org/archives/cairo/attachments/20091119/436a3ea1/attachment.pgp 

More information about the cairo mailing list