fixes to wxImage::ResambleBox() (patch 1843902)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50901 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -298,6 +298,7 @@ All:
|
|||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
- Added wxWindow::GetNextSibling() and GetPrevSibling()
|
- Added wxWindow::GetNextSibling() and GetPrevSibling()
|
||||||
|
- Improve wximage::ResampleBox() (Mihai Ciocarlie)
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
|
||||||
|
@@ -538,13 +538,8 @@ wxImage wxImage::ResampleBox(int width, int height) const
|
|||||||
const int scale_factor_x_2 = (int)(scale_factor_x / 2);
|
const int scale_factor_x_2 = (int)(scale_factor_x / 2);
|
||||||
const int scale_factor_y_2 = (int)(scale_factor_y / 2);
|
const int scale_factor_y_2 = (int)(scale_factor_y / 2);
|
||||||
|
|
||||||
// If we want good-looking results we need to pre-blur the image a bit first
|
unsigned char* src_data = M_IMGDATA->m_data;
|
||||||
wxImage src_image(*this);
|
unsigned char* src_alpha = M_IMGDATA->m_alpha;
|
||||||
src_image = src_image.BlurHorizontal(scale_factor_x_2);
|
|
||||||
src_image = src_image.BlurVertical(scale_factor_y_2);
|
|
||||||
|
|
||||||
unsigned char* src_data = src_image.GetData();
|
|
||||||
unsigned char* src_alpha = src_image.GetAlpha();
|
|
||||||
unsigned char* dst_data = ret_image.GetData();
|
unsigned char* dst_data = ret_image.GetData();
|
||||||
unsigned char* dst_alpha = NULL;
|
unsigned char* dst_alpha = NULL;
|
||||||
|
|
||||||
@@ -576,7 +571,7 @@ wxImage wxImage::ResampleBox(int width, int height) const
|
|||||||
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 )
|
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);
|
||||||
@@ -584,11 +579,11 @@ wxImage wxImage::ResampleBox(int width, int height) const
|
|||||||
i++ )
|
i++ )
|
||||||
{
|
{
|
||||||
// Don't average edge pixels
|
// Don't average edge pixels
|
||||||
if ( i < 0 || i > M_IMGDATA->m_width )
|
if ( i < 0 || i > M_IMGDATA->m_width - 1 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Calculate the actual index in our source pixels
|
// Calculate the actual index in our source pixels
|
||||||
src_pixel_index = src_y * M_IMGDATA->m_width + src_x;
|
src_pixel_index = j * M_IMGDATA->m_width + i;
|
||||||
|
|
||||||
sum_r += src_data[src_pixel_index * 3 + 0];
|
sum_r += src_data[src_pixel_index * 3 + 0];
|
||||||
sum_g += src_data[src_pixel_index * 3 + 1];
|
sum_g += src_data[src_pixel_index * 3 + 1];
|
||||||
|
Reference in New Issue
Block a user