Changed behaviour of wxImageResizeQuality parameter in wxImage.Scale and wxImage.Rescale.
Made the following changes: * Formerly specifying to resize using wxIMAGE_QUALITY_BICUBIC or wxIMAGE_QUALITY_BILINEAR could result in the ResampleBox method being used. Now always resize with the method that the user actually specified. * Added wxIMAGE_QUALITY_BOX_AVERAGE to explicitly allow resizing with the ResampleBox method. * Previously wxIMAGE_QUALITY_HIGH was equal to wxIMAGE_QUALITY_BICUBIC. It has been changed to use wxIMAGE_QUALITY_BOX_AVERAGE when reducing the size of an image and wxIMAGE_QUALITY_BICUBIC in all other cases. Closes #12845. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67203 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -62,12 +62,13 @@ enum wxImageResizeQuality
|
|||||||
wxIMAGE_QUALITY_NEAREST = 0,
|
wxIMAGE_QUALITY_NEAREST = 0,
|
||||||
wxIMAGE_QUALITY_BILINEAR = 1,
|
wxIMAGE_QUALITY_BILINEAR = 1,
|
||||||
wxIMAGE_QUALITY_BICUBIC = 2,
|
wxIMAGE_QUALITY_BICUBIC = 2,
|
||||||
|
wxIMAGE_QUALITY_BOX_AVERAGE = 3,
|
||||||
|
|
||||||
// default quality is low (but fast)
|
// default quality is low (but fast)
|
||||||
wxIMAGE_QUALITY_NORMAL = wxIMAGE_QUALITY_NEAREST,
|
wxIMAGE_QUALITY_NORMAL = wxIMAGE_QUALITY_NEAREST,
|
||||||
|
|
||||||
// highest (but best) quality
|
// highest (but best) quality
|
||||||
wxIMAGE_QUALITY_HIGH = wxIMAGE_QUALITY_BICUBIC
|
wxIMAGE_QUALITY_HIGH
|
||||||
};
|
};
|
||||||
|
|
||||||
// alpha channel values: fully transparent, default threshold separating
|
// alpha channel values: fully transparent, default threshold separating
|
||||||
|
@@ -39,10 +39,24 @@ enum wxImageResizeQuality
|
|||||||
/// Highest quality but slowest execution time.
|
/// Highest quality but slowest execution time.
|
||||||
wxIMAGE_QUALITY_BICUBIC,
|
wxIMAGE_QUALITY_BICUBIC,
|
||||||
|
|
||||||
/// Default image resizing algorithm used by wxImage::Scale().
|
/**
|
||||||
|
Use surrounding pixels to calculate an average that will be used for
|
||||||
|
new pixels. This method is typically used when reducing the size of
|
||||||
|
an image.
|
||||||
|
wxIMAGE_QUALITY_BOX_AVERAGE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
Default image resizing algorithm used by wxImage::Scale(). Currently
|
||||||
|
the same as wxIMAGE_QUALITY_NEAREST.
|
||||||
|
*/
|
||||||
wxIMAGE_QUALITY_NORMAL,
|
wxIMAGE_QUALITY_NORMAL,
|
||||||
|
|
||||||
/// Best image resizing algorithm, currently same as wxIMAGE_QUALITY_BICUBIC.
|
/**
|
||||||
|
Best image resizing algorithm. Since version 2.9.2 this results in
|
||||||
|
wxIMAGE_QUALITY_BOX_AVERAGE being used when reducing the size of the
|
||||||
|
image (meaning that both the new width and height will be smaller than
|
||||||
|
the original size). Otherwise wxIMAGE_QUALITY_BICUBIC is used.
|
||||||
|
*/
|
||||||
wxIMAGE_QUALITY_HIGH
|
wxIMAGE_QUALITY_HIGH
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -442,23 +442,16 @@ wxImage::Scale( int width, int height, wxImageResizeQuality quality ) const
|
|||||||
if ( old_width == width && old_height == height )
|
if ( old_width == width && old_height == height )
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
// resample the image using either the nearest neighbourhood, bilinear or
|
if (quality == wxIMAGE_QUALITY_HIGH)
|
||||||
// bicubic method as specified
|
{
|
||||||
|
quality = (width < old_width && height < old_height)
|
||||||
|
? wxIMAGE_QUALITY_BOX_AVERAGE
|
||||||
|
: wxIMAGE_QUALITY_BICUBIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resample the image using the method as specified.
|
||||||
switch ( quality )
|
switch ( quality )
|
||||||
{
|
{
|
||||||
case wxIMAGE_QUALITY_BICUBIC:
|
|
||||||
case wxIMAGE_QUALITY_BILINEAR:
|
|
||||||
// both of these algorithms should be used for up-sampling the
|
|
||||||
// image only, when down-sampling always use box averaging for best
|
|
||||||
// results
|
|
||||||
if ( width < old_width && height < old_height )
|
|
||||||
image = ResampleBox(width, height);
|
|
||||||
else if ( quality == wxIMAGE_QUALITY_BILINEAR )
|
|
||||||
image = ResampleBilinear(width, height);
|
|
||||||
else if ( quality == wxIMAGE_QUALITY_BICUBIC )
|
|
||||||
image = ResampleBicubic(width, height);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxIMAGE_QUALITY_NEAREST:
|
case wxIMAGE_QUALITY_NEAREST:
|
||||||
if ( old_width % width == 0 && old_width >= width &&
|
if ( old_width % width == 0 && old_width >= width &&
|
||||||
old_height % height == 0 && old_height >= height )
|
old_height % height == 0 && old_height >= height )
|
||||||
@@ -468,6 +461,18 @@ wxImage::Scale( int width, int height, wxImageResizeQuality quality ) const
|
|||||||
|
|
||||||
image = ResampleNearest(width, height);
|
image = ResampleNearest(width, height);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case wxIMAGE_QUALITY_BILINEAR:
|
||||||
|
image = ResampleBilinear(width, height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxIMAGE_QUALITY_BICUBIC:
|
||||||
|
image = ResampleBicubic(width, height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxIMAGE_QUALITY_BOX_AVERAGE:
|
||||||
|
image = ResampleBox(width, height);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the original image has a mask, apply the mask to the new image
|
// If the original image has a mask, apply the mask to the new image
|
||||||
|
Reference in New Issue
Block a user