RGB channels are set to zero if alpha is 0.

Bram Stolk <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CABYXEku2Tq++UBRwC8c_aC_EhGFUG6WU7Kg5a0KaH2ALw-LKzw@mail.gmail.com>
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.set_line_width(0.01)

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

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

surface.write_to_png(filename + '.png')
cr.show_page()
surface.finish()



-- 
Owner/Director of Game Studio Abraham Stolk Inc.
Vancouver BC, Canada
[email protected]

-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
histo.png (image/png, 10.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.