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

Skip to content

Rastized background color #2479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from 0 to 1 worries me. Could you provide some more information about what this PR achieves in the description please?


assert_array_equal(data, arr_buf)

Expand Down
9 changes: 5 additions & 4 deletions src/_backend_agg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this value changed from (0, 0, 0, 0) to (1, 1, 1, 0)? This was a change I introduced in d8fce7b which I'm surprised is not triggering some of the tests I added to fail. Would you mind providing some more detail in the description of the PR please?

{
_VERBOSE("RendererAgg::RendererAgg");
unsigned stride(width*4);
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}
Expand Down
3 changes: 3 additions & 0 deletions src/_backend_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ class RendererAgg: public Py::PythonExtension<RendererAgg>

const int debug;

agg::rgba _fill_color;


protected:
double points_to_pixels(const Py::Object& points);
agg::rgba rgb_to_color(const Py::SeqBase<Py::Object>& rgb, double alpha);
Expand Down