From 2263961d4de14fdca5ecbc48de480107e3122f39 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Mon, 7 Sep 2015 17:58:36 +0100 Subject: [PATCH] gui: Simplify and rework EmbeddedImage class The wxImage Scale/Rescale methods with wxIMAGE_QUALITY_HIGH upsamples and downsamples using the bicubic and box resampling methods respectively, so let's just use that instead of the ResampleBox method, which is undocumentated and probably shouldn't be used. The Rescale function also modified the image when it was not supposed to. Fix it, and rename it scale to avoid confusion with the wxWidgets class. --- pcsx2/gui/Resources/EmbeddedImage.h | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/pcsx2/gui/Resources/EmbeddedImage.h b/pcsx2/gui/Resources/EmbeddedImage.h index b68199802d..91051ecd08 100644 --- a/pcsx2/gui/Resources/EmbeddedImage.h +++ b/pcsx2/gui/Resources/EmbeddedImage.h @@ -26,8 +26,7 @@ class IEmbeddedImage { public: virtual const wxImage& Get()=0; - virtual wxImage Rescale( int width, int height )=0; - virtual wxImage Resample( int width, int height )=0; + virtual wxImage Scale( int width, int height )=0; }; ////////////////////////////////////////////////////////////////////////////////////////// @@ -59,7 +58,7 @@ protected: m_Image.LoadFile( joe, ImageType::GetFormat() ); if( m_ResampleTo.IsFullySpecified() && ( m_ResampleTo.GetWidth() != m_Image.GetWidth() || m_ResampleTo.GetHeight() != m_Image.GetHeight() ) ) - m_Image = m_Image.ResampleBox( m_ResampleTo.GetWidth(), m_ResampleTo.GetHeight() ); + m_Image.Rescale( m_ResampleTo.GetWidth(), m_ResampleTo.GetHeight(), wxIMAGE_QUALITY_HIGH ); } } @@ -107,31 +106,15 @@ public: // ------------------------------------------------------------------------ // Performs a pixel resize of the loaded image and returns a new image handle (EmbeddedImage - // is left unmodified). Useful for creating ugly versions of otherwise nice graphics. Do - // us all a favor and use Resample() instead. + // is left unmodified). // - // (this method included for sake of completeness only). - // - wxImage Rescale( int width, int height ) - { - _loadImage(); - if( width != m_Image.GetWidth() || height != m_Image.GetHeight() ) - return m_Image.Rescale( width, height ); - else - return m_Image; - } - // ------------------------------------------------------------------------ - // Implementation Note: This function uses wxWidgets ResampleBox method to resize the image. - // wxWidgets ResampleBicubic appears to be buggy and produces fairly poor results when down- - // sampling images (basically resembles a pixel resize). ResampleBox produces much cleaner - // results. - // - wxImage Resample( int width, int height ) + wxImage Scale( int width, int height ) { _loadImage(); + // Not strictly necessary - wxWidgets does the dimensions check anyway. if( width != m_Image.GetWidth() || height != m_Image.GetHeight() ) - return m_Image.ResampleBox( width, height ); + return m_Image.Scale( width, height, wxIMAGE_QUALITY_HIGH ); else return m_Image; }