[cairo] RGB channels are set to zero if alpha is 0.

Bram Stolk b.stolk at gmail.com
Sun Aug 27 00:55:54 UTC 2017

Hi there,

Cairo is treating colours with alpha=zero incorrectly.
If alpha is zero, the red green and blue channels are zeroed by cairo, even
if they contain non zero r/g/b values.

To demonstrate this bug, I wrote this python-cairo program that creates an
image with two colours.
The left half of the image is set to 1,1,1,0.
The right half of the image is set to 1,1,1,1

When cairo writes out the PNG, the left half of the image is incorrect.
The pixels are 0,0,0,0 instead of 1,1,1,0.


The test program:

#! /usr/bin/env python
import cairo
from math import pi, sqrt

width = 120
height = 120
filename = "out"

surface = cairo.SVGSurface(filename + '.svg', width, height)
cr = cairo.Context(surface)

cr.scale(width, height)

cr.rectangle(0, 0, 0.5, 1)
cr.set_source_rgba(1, 1, 1, 0/255.0)

cr.set_source_rgba(1,1,1, 1/255.0)

surface.write_to_png(filename + '.png')

Owner/Director of Game Studio Abraham Stolk Inc.
Vancouver BC, Canada
b.stolk at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170826/71f7d433/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: histo.png
Type: image/png
Size: 11166 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170826/71f7d433/attachment.png>

More information about the cairo mailing list