Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22806ae

Browse files
committed
Fix image alpha in PNG backend
1 parent f3895f9 commit 22806ae

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,13 @@ def test_image_alpha():
176176
np.random.seed(0)
177177
Z = np.random.rand(6, 6)
178178

179-
plt.subplot(121)
179+
plt.subplot(131)
180+
plt.imshow(Z, alpha=1.0, interpolation='none')
181+
182+
plt.subplot(132)
180183
plt.imshow(Z, alpha=0.5, interpolation='none')
181184

182-
plt.subplot(122)
185+
plt.subplot(133)
183186
plt.imshow(Z, alpha=0.5, interpolation='nearest')
184187

185188
@cleanup

src/_backend_agg_wrapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ static PyObject *PyRendererAgg_draw_image(PyRendererAgg *self, PyObject *args, P
299299
x = mpl_round(x);
300300
y = mpl_round(y);
301301

302+
gc.alpha = 1.0;
302303
CALL_CPP("draw_image", (self->x->draw_image(gc, x, y, image)));
303304

304305
Py_RETURN_NONE;

0 commit comments

Comments
 (0)