[cairo] Corrupted image surface in pycairo 1.0.2
Steven Chaplin
stevech1097 at yahoo.com.au
Sun Jul 23 18:38:43 PDT 2006
On Mon, 2006-07-24 at 01:33 +0200, Sebastian Koppehel wrote:
> Hi,
>
> the following Python program produces an empty, transparent image as
> expected:
>
> import cairo
>
> t = cairo.ImageSurface(cairo.FORMAT_ARGB32, 180, 180)
> t.write_to_png("bla.png")
>
> The following produces, on my system, a mostly empty image, but with
> stray pixels:
>
> import cairo
>
> s = cairo.ImageSurface.create_from_png("knight.png")
> t = cairo.ImageSurface(cairo.FORMAT_ARGB32, 180, 180)
> t.write_to_png("bla.png")
>
> It's the unrelated loading of another image which causes the corruption;
> it does depend on the other image and on the dimensions of t. There are
> sizes of t where it doesn't get corrupted at all.
>
> For reference, here are my image files:
>
> http://bastisoft.de/temp/knight.png
> http://bastisoft.de/temp/bla.png
>
> >>> cairo.version, cairo.cairo_version_string()
> ('1.0.2', '1.0.4')
>
> Unfortunately I cannot test newer versions of pycairo at the moment. I
> currently work around this by explicitly clearing the surface:
>
> cr = cairo.Context(t)
> cr.set_operator(cairo.OPERATOR_SOURCE)
> cr.set_source_rgba(0, 0, 0, 0)
> cr.paint()
>
> But I figure I shouldn't have to do this.
>
> - Sebastian
I believe cairo 1.0.2 (and pycairo 1.0.2) creates an ImageSurface in an
undefined state and you DO need to explicitly clear the surface. The
behaviour was changed in cairo 1.2.0 (and pycairo 1.2.0) which now
creates an ImageSurface and clears it.
I looked at the NEWS file for cairo 1.2.0 to confirm this but could not
find any mention of it.
Steve
Send instant messages to your online friends http://au.messenger.yahoo.com
More information about the cairo
mailing list