[cairo] Gray-scale support in Cairo

t_list at mailbox.org t_list at mailbox.org
Thu Sep 24 08:03:27 UTC 2020


Hello there,

I am dealing with large TIFF files of planetary data which are mostly gray-scale. I noticed that the cairo image format [0] does not define an 8-bit gray-scale format. The closest to this would be the 'A8' however, this is made for alpha values.

Since cairo is around for quite some time, I suppose there is a way to deal with gray-scale images, so I wonder what the recommended way is.

Right now to make this work I can either save each pixel value three times, or use the A8 format and put a white background behind the image.
The first workaround is sub-optimal because it results in a huge waste of memory and additional compute time and mind you I am dealing with huge image data.
The second approach kinda works but it feels like a hacky solution nonetheless and might cause other rendering problems.

As a little side-note: I am not using cairo directly but rely on the cairo bindings for Rust (cairo-rs) since my application is written in Rust.

Any help how to deal with this, would be much appreciated.

[0]: https://www.cairographics.org/manual/cairo-Image-Surfaces.html#cairo-format-t


- Raphael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20200924/d6bd23f7/attachment.htm>


More information about the cairo mailing list