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