[cairo] X11 image data rendering problems (Xrender ?)
Julien Danjou
julien at danjou.info
Mon Mar 24 02:32:26 PDT 2008
At 1206310014 time_t, Bertram Felgenhauer wrote:
> Imlib2's ARGB32 format is, however, incompatible with cairo's, because
> cairo expects pre-multiplied alpha images. (This is mentioned in passing
> at
> http://cairographics.org/manual/cairo-Image-Surfaces.html#cairo-format-t
> but I don't know whether the docs explain this in detail.)
Ah, that was a close one. And I did see this sentence in the API, but
did not know that the word 'pre-multiplied' was so important.
I did not use your solution, because it seems that blending does not act
the same way at each run, but I now compute pre-multiplied values
myself, and it works much better than before:
dataimg = p_new(unsigned char, w * h * 4);
for(i = 0; i < size; i++, dataimg += 4)
{
dataimg[3] = (data[i] >> 24) & 0xff; /* A */
/* cairo wants pre-multiplied alpha */
alpha = dataimg[3] / 255.0;
dataimg[2] = ((data[i] >> 16) & 0xff) * alpha; /* R */
dataimg[1] = ((data[i] >> 8) & 0xff) * alpha; /* G */
dataimg[0] = (data[i] & 0xff) * alpha; /* B */
}
Thanks a lot Bertram,
And keep doing such good work guys,
Cheers,
--
Julien Danjou
// ᐰ <julien at danjou.info> http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.cairographics.org/archives/cairo/attachments/20080324/3deafaf5/attachment.pgp
More information about the cairo
mailing list