mirror of https://github.com/PCSX2/pcsx2.git
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.
This commit is contained in:
parent
ddc03cbccf
commit
2263961d4d
|
@ -26,8 +26,7 @@ class IEmbeddedImage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual const wxImage& Get()=0;
|
virtual const wxImage& Get()=0;
|
||||||
virtual wxImage Rescale( int width, int height )=0;
|
virtual wxImage Scale( int width, int height )=0;
|
||||||
virtual wxImage Resample( int width, int height )=0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -59,7 +58,7 @@ protected:
|
||||||
m_Image.LoadFile( joe, ImageType::GetFormat() );
|
m_Image.LoadFile( joe, ImageType::GetFormat() );
|
||||||
|
|
||||||
if( m_ResampleTo.IsFullySpecified() && ( m_ResampleTo.GetWidth() != m_Image.GetWidth() || m_ResampleTo.GetHeight() != m_Image.GetHeight() ) )
|
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
|
// 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
|
// is left unmodified).
|
||||||
// us all a favor and use Resample() instead.
|
|
||||||
//
|
//
|
||||||
// (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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
wxImage Scale( int width, int height )
|
||||||
// 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 )
|
|
||||||
{
|
{
|
||||||
_loadImage();
|
_loadImage();
|
||||||
|
// Not strictly necessary - wxWidgets does the dimensions check anyway.
|
||||||
if( width != m_Image.GetWidth() || height != m_Image.GetHeight() )
|
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
|
else
|
||||||
return m_Image;
|
return m_Image;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue