🌐 AI搜索 & 代理 主页
Skip to content
Open
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
9 changes: 9 additions & 0 deletions extern/agg24-svn/include/agg_image_filters.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,25 @@ namespace agg
double r = filter.radius();
realloc_lut(r);
unsigned i;
#ifndef MPL_FIX_AGG_IMAGE_FILTER_LUT_BUGS
unsigned pivot = diameter() << (image_subpixel_shift - 1);
for(i = 0; i < pivot; i++)
#else
unsigned pivot = (diameter() << (image_subpixel_shift - 1)) - 1;
for(i = 0; i < pivot + 1; i++)
#endif
{
double x = double(i) / double(image_subpixel_scale);
double y = filter.calc_weight(x);
m_weight_array[pivot + i] =
m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale);
}
unsigned end = (diameter() << image_subpixel_shift) - 1;
#ifndef MPL_FIX_AGG_IMAGE_FILTER_LUT_BUGS
m_weight_array[0] = m_weight_array[end];
Copy link
Contributor Author

@ayshih ayshih Jun 18, 2025

Choose a reason for hiding this comment

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

This line is one of the bugs. 0 and end are different distances from pivot, so the corresponding weights typically should not be the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please put the new version under a macro guard, as was done in #28122, so that we keep a track of what's the original Agg and what we changed on top of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, done

Copy link
Contributor Author

@ayshih ayshih Jun 18, 2025

Choose a reason for hiding this comment

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

It turns out that I can't add a preprocessor definition in _image_resample.h a la #28122. There is buggy code in agg_image_filters.cpp that needs to be skipped, but since it is a CPP file rather than a H file, it gets compiled separately with no awareness of _image_resample.h. I have put the preprocessor definition (MPL_FIX_IMAGE_FILTER_LUT_BUGS) here at the top of agg_image_filters.h, which is lower level than would be nice, but at least still makes it clear what is custom code.

Copy link
Member

Choose a reason for hiding this comment

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

You could also put the define in the corresponding meson.build if you prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that's a nicer approach. Done!

#else
m_weight_array[end] = (int16)iround(filter.calc_weight(diameter() / 2) * image_filter_scale);
#endif
if(normalization)
{
normalize();
Expand Down
8 changes: 8 additions & 0 deletions extern/agg24-svn/include/agg_span_interpolator_linear.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ namespace agg
//----------------------------------------------------------------
void begin(double x, double y, unsigned len)
{
#ifdef MPL_FIX_AGG_INTERPOLATION_ENDPOINT_BUG
len -= 1;
#endif

double tx;
double ty;

Expand All @@ -75,6 +79,10 @@ namespace agg
//----------------------------------------------------------------
void resynchronize(double xe, double ye, unsigned len)
{
#ifdef MPL_FIX_AGG_INTERPOLATION_ENDPOINT_BUG
len -= 1;
#endif

m_trans->transform(&xe, &ye);
m_li_x = dda2_line_interpolator(m_li_x.y(), iround(xe * subpixel_scale), len);
m_li_y = dda2_line_interpolator(m_li_y.y(), iround(ye * subpixel_scale), len);
Expand Down
2 changes: 2 additions & 0 deletions extern/agg24-svn/src/agg_image_filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ namespace agg
}
}

#ifndef MPL_FIX_AGG_IMAGE_FILTER_LUT_BUGS
unsigned pivot = m_diameter << (image_subpixel_shift - 1);

for(i = 0; i < pivot; i++)
Expand All @@ -96,6 +97,7 @@ namespace agg
}
unsigned end = (diameter() << image_subpixel_shift) - 1;
m_weight_array[0] = m_weight_array[end];
#endif
}


Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,8 @@ def _init(self):
_patch = np.empty((s[0], s[1], 4))
_patch[:, :, :3] = self.patch
_patch[:, :, 3] = 1
transform = mpl.transforms.Affine2D().translate(-0.5, -0.5)\
# Shift by an additional Agg subpixel (1/256 pixel) to match previous behavior
transform = mpl.transforms.Affine2D().translate(-0.5 - 1/256, -0.5 - 1/256)\
.scale(self.N / (s[1] - 1), self.N / (s[0] - 1))
self._lut = np.empty((self.N, self.N, 4))

Expand Down
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/imshow.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/imshow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 41 additions & 30 deletions lib/matplotlib/tests/baseline_images/test_axes/imshow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 75 additions & 62 deletions lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/matplotlib/tests/baseline_images/test_image/downsampling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/matplotlib/tests/baseline_images/test_image/image_cliprect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading