[cairo] How to write to a CAIRO_FORMAT_A8 image surface?

Manfred Kogler manfred.kogler at gmail.com
Tue Oct 2 02:33:24 PDT 2012


Currently I am rendering postscript commands using Cairo to a
CAIRO_FORMAT_RGB24 image surface. This image then I have to transfer/map to
the framebuffer of a display device. One pixel in that display framebuffer
is an 8-bit index into a predefined color table. Hence, when transferring
the CAIRO_FORMAT_RGB24 image surface into the 8-bit display framebuffer
each RGB-pixel is mapped to the respective 8-bit color index and this index
value is written to the framebuffer at the respective position. This works
fine, only it is a bit slow since rendering a frame always involves
copying/transferring the whole image into that 8-bit framebuffer.

To get rid of copying/transferring the image I thought of using
cairo_image_surface_create_for_data(frame_buffer, CAIRO_FORMAT_A8, ...). My
plan is to not write an intermediary RGB image anymore but to somehow
directly write the RGB-mapped color-index-table-values to that
A8-byte-buffer. I tried several approaches but could not figure out how to
write one byte (color index) to that CAIRO_FORMAT_A8 image surface and am
not sure whether it is possible at all.

Effectively, my question reduces to the following point:
Is there a way to write (stroke/fill/paint/...) some byte unchanged to a
CAIRO_FORMAT_A8 image surface?

Is there some way to do what I want?

Many thanks and best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20121002/ae0d60a4/attachment.html>

More information about the cairo mailing list