[Python-modules-team] Bug#661005: python-cairo: ImageSurface.write_to_png() transparency fails

John Hedges john at drystone.co.uk
Thu Feb 23 13:59:36 UTC 2012


Package: python-cairo
Version: 1.8.8-1+b2
Severity: normal

Dear Maintainer,

It seems writing a png when a surface is fully opaque causes the alpha
channel to be supressed in subsequent writes.


#!/usr/bin/python
import cairo

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
ctx = cairo.Context(surface)
ctx.set_operator(cairo.OPERATOR_SOURCE)
ctx.set_source_rgba(1,1,1,1) # fully opaque
ctx.paint()
surface.write_to_png("i1.png") # i1.png is an opaque white square.
ctx.set_source_rgba(1,1,1,0)
ctx.paint()
surface.write_to_png("i2.png") # i2.png is an opaque black square (fail).

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
ctx = cairo.Context(surface)
ctx.set_operator(cairo.OPERATOR_SOURCE)
ctx.set_source_rgba(1,1,1,1)
ctx.paint()
# no write_to_png at this point
ctx.set_source_rgba(1,1,1,0)
ctx.paint()
surface.write_to_png("i3.png") # i3.png is a transparent square

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
ctx = cairo.Context(surface)
ctx.set_operator(cairo.OPERATOR_SOURCE)
ctx.set_source_rgba(1,1,1,0.9) # some transparency
ctx.paint()
surface.write_to_png("i4.png") # i4.png is a nearly opaque white square.
ctx.set_source_rgba(1,1,1,0)
ctx.paint()
surface.write_to_png("i5.png") # i5.png is a transparent square


Cheers
John


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.1.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages python-cairo depends on:
ii  libc6           2.13-26
ii  libcairo2       1.10.2-6.2
ii  python          2.7.2-9
ii  python-support  1.0.14

python-cairo recommends no packages.

python-cairo suggests no packages.

-- no debconf information





More information about the Python-modules-team mailing list