[cairo] Bug drawing PNG images with transparency
cworth at cworth.org
Tue Aug 1 12:10:43 PDT 2006
On Tue, 01 Aug 2006 13:43:23 +0200, Franz Schmid wrote:
> Hi all,
> during the development of Scribus i've encountered a strange bug
> with the drawing of images with an alpha channel.
Thanks for the report. I am having a bit of trouble figuring out what
bug you are trying to report here. Perhaps you can give me a few more
For starters, which backend are you using?
> The code i've used to draw the images is as following:
> cairo_set_fill_rule(m_cr, cairo_get_fill_rule(m_cr));
> cairo_surface_t *image2;
> image2 = cairo_image_surface_create_for_data ((uchar*)image->bits(), CAIRO_FORMAT_ARGB32, image->width(), image->height(), image->width()*4);
> cairo_scale(m_cr, m_zoomFactor, m_zoomFactor);
> cairo_set_source_surface (m_cr, image2, 0, 0);
> cairo_paint_with_alpha(m_cr, fill_trans);
> cairo_surface_destroy (image2);
> I've attached four images to illustrate the problem:
> drawbug2.png shows as it should be
For "as it should be" is that with m_zoomFactor set to 1.0 and
fill_trans set to 1.0 ? And is this image the result of correct
behavior from cairo in this case? Or is this an independent
representation of the result you want?
And I assume the destination surface is solid yellow before the
drawing code above?
> drawbug1.png shows the display with m_zoomFactor set to 0.5
> drawbug3.png shows the display with fill_trans set to 0.5
So could you describe the bug(s) you are seeing here?
Let me guess at what you might be seeing as problems: 1) Portions of
the image that are entirely transparent are resulting in white in the
final result. 2) Areas outside the image are being affected in the
One step that would clear up almost all of the above questions would
be to write (or adapt) one of the tests in the cairo test suite to
replicate your problem. A great place to start would be the
paint-with-alpha test which looks very much like your test case. What
happens if you do the following in a cairo source tree on your system:
If that test doesn't replicate your problem, can you identify some
minimal change to the test that would cause it to replicate your
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060801/822a08c5/attachment.pgp
More information about the cairo