Changed wxImage.ResampleBox to always use a box size of at least 2 by 2 pixels.

Previously when resizing by more than 50% (for example resizing from 100x100 to 51x51 or 140x140) a box size of 1x1 would be used which effectively would give the same result as using nearest neighbour. Make sure that at least a box size of 2x2 pixels is always used.

Patch by scottb, see also #12845.



git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67202 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Dimitri Schoolwerth
2011-03-15 16:37:04 +00:00
parent bd448041e7
commit 41774f1b20

View File

@@ -589,16 +589,16 @@ wxImage wxImage::ResampleBox(int width, int height) const
averaged_pixels = 0;
sum_r = sum_g = sum_b = sum_a = 0.0;
for ( int j = int(src_y - scale_factor_y/2.0 + 1);
j <= int(src_y + scale_factor_y_2);
for ( int j = int(src_y - scale_factor_y/2.0 + 1), k = j;
j <= int(src_y + scale_factor_y_2) || j < k + 2;
j++ )
{
// We don't care to average pixels that don't exist (edges)
if ( j < 0 || j > M_IMGDATA->m_height - 1 )
continue;
for ( int i = int(src_x - scale_factor_x/2.0 + 1);
i <= src_x + scale_factor_x_2;
for ( int i = int(src_x - scale_factor_x/2.0 + 1), e = i;
i <= src_x + scale_factor_x_2 || i < e + 2;
i++ )
{
// Don't average edge pixels