diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 6f2ec0c83188..6838c982b9f5 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -147,7 +147,8 @@ def test_imsave_color_alpha(): # Wherever alpha values were rounded down to 0, the rgb values all get set # to 0 during imsave (this is reasonable behaviour). # Recreate that here: - data[data[:, :, 3] == 0] = 0 + for j in range(3): + data[data[:, :, 3] == 0, j] = 1 assert_array_equal(data, arr_buf) diff --git a/src/_backend_agg.cpp b/src/_backend_agg.cpp index 8914f3ffd199..c65af527e30a 100644 --- a/src/_backend_agg.cpp +++ b/src/_backend_agg.cpp @@ -421,7 +421,8 @@ RendererAgg::RendererAgg(unsigned int width, unsigned int height, double dpi, rendererAA(), rendererBin(), theRasterizer(), - debug(debug) + debug(debug), + _fill_color(agg::rgba(1, 1, 1, 0)) { _VERBOSE("RendererAgg::RendererAgg"); unsigned stride(width*4); @@ -430,7 +431,7 @@ RendererAgg::RendererAgg(unsigned int width, unsigned int height, double dpi, renderingBuffer.attach(pixBuffer, width, height, stride); pixFmt.attach(renderingBuffer); rendererBase.attach(pixFmt); - rendererBase.clear(agg::rgba(0, 0, 0, 0)); + rendererBase.clear(_fill_color); rendererAA.attach(rendererBase); rendererBin.attach(rendererBase); hatchRenderingBuffer.attach(hatchBuffer, HATCH_SIZE, HATCH_SIZE, @@ -1287,7 +1288,7 @@ void RendererAgg::_draw_path(path_t& path, bool has_clippath, pixfmt hatch_img_pixf(hatchRenderingBuffer); renderer_base rb(hatch_img_pixf); renderer_aa rs(rb); - rb.clear(agg::rgba(0.0, 0.0, 0.0, 0.0)); + rb.clear(_fill_color); rs.color(gc.color); try { @@ -2425,7 +2426,7 @@ RendererAgg::clear(const Py::Tuple& args) _VERBOSE("RendererAgg::clear"); args.verify_length(0); - rendererBase.clear(agg::rgba(0, 0, 0, 0)); + rendererBase.clear(_fill_color); return Py::Object(); } diff --git a/src/_backend_agg.h b/src/_backend_agg.h index 7612942b9c06..65cc60aec92c 100644 --- a/src/_backend_agg.h +++ b/src/_backend_agg.h @@ -241,6 +241,9 @@ class RendererAgg: public Py::PythonExtension const int debug; + agg::rgba _fill_color; + + protected: double points_to_pixels(const Py::Object& points); agg::rgba rgb_to_color(const Py::SeqBase& rgb, double alpha);