[cairo] Bug drawing PNG images with transparency
Franz.Schmid at altmuehlnet.de
Tue Aug 1 14:03:46 PDT 2006
Carl Worth schrieb:
> On Tue, 01 Aug 2006 13:43:23 +0200, Franz Schmid wrote:
>>during the development of Scribus i've encountered a strange bug
>>with the drawing of images with an alpha channel.
> Hi Franz,
> 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?
I'm using the image backend.
>>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?
Correct, and this is the expected correct behaviour for a m_zoomFactor = 1.0
and fill_trans = 1.0
> 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
> fill_trans case.
Case 1 is the bug, transparent areas of the image become white when
you change either the m_zoomFactor or fill_trans to any value != 1.0
Furthermore some colors inside the image are changing strangely when
you have a fill_trans != 1.0, and this is dependend of the value of
> 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:
> cd test
> make paint-with-alpha
> If that test doesn't replicate your problem, can you identify some
> minimal change to the test that would cause it to replicate your
Will try to do that tomorrow.
Anyway thanks for your time to look into that problem.
More information about the cairo