[cairo] Corrupted image surface in pycairo 1.0.2

Vladimir Vukicevic vladimirv at gmail.com
Sun Jul 23 18:31:29 PDT 2006


Cairo versions prior to 1.2 (maybe some point release of 1.0 as well,
not sure) did not clear the image surface data; it was assumed that
the user would do so.  So, you're seeing the contents of a random
chunk of memory, usually what the kernel cleared before giving back to
the program.  Cairo 1.2 explicitly clears the memory of all image
surfaces upon creation.  So, your workaround is correct, though I
would suggest using CAIRO_OPERATOR_CLEAR (and not bothering to set a
source color).

   - Vlad


On 7/23/06, Sebastian Koppehel <basti at bastisoft.de> 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
>
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
>


More information about the cairo mailing list