You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The gtk3agg backend works by drawing the ARGB32 buffer (from Agg) onto a
cairo context (passed by gtk3). However, cairo wants a *premultiplied*
ARGB32 buffer (i.e., where 100% blue with 50% transparency is
represented by (r=0%, g=0%, b=50%, a=50%) instead of (r=0%, g=0%,
b=100%, a=50%), which we didn't do before.
This is only apparent if the entire buffer contains some transparency,
e.g. if the figure background is transparent. Consider e.g. under
gtk3agg:
from pylab import *
rcParams["figure.facecolor"] = (0, 0, 0, 0)
gca()
show()
Without the patch, the area surrounding the axes is white (because of
the misinterpretation of premultiplied alpha). With the patch, it is
(correctly) gray, which is the background color of the gtk widget.
(Note that when running the example under qt5agg or tkagg, the situation
is complicated by the fact that these backends themselves set the widget
background color to white rather than gray.)
As a comparison point, qt5agg builds the QImage using Format_ARGB32,
instead of Format_ARB32_Premultiplied; i.e. Qt provides its own
conversion from non-premultiplied to premultiplied.
The premultiplication step involves allocating a full new buffer, so
check whether there is actually any transparency before doing it.
0 commit comments