Move duplicated code to rescale the bitmap to the shared function

This commit is contained in:
Artur Wieczorek
2020-04-10 20:45:34 +02:00
parent f95d6463d3
commit c4f5fd3581
4 changed files with 35 additions and 42 deletions

View File

@@ -1838,6 +1838,36 @@ bool wxPropertyGrid::IsSmallScreen()
// -----------------------------------------------------------------------
// static
wxBitmap wxPropertyGrid::RescaleBitmap(const wxBitmap& srcBmp,
double scaleX, double scaleY)
{
int w = wxRound(srcBmp.GetWidth()*scaleX);
int h = wxRound(srcBmp.GetHeight()*scaleY);
#if wxUSE_IMAGE
// Here we use high-quality wxImage scaling functions available
wxImage img = srcBmp.ConvertToImage();
img.Rescale(w, h, wxIMAGE_QUALITY_HIGH);
wxBitmap dstBmp(img);
#else // !wxUSE_IMAGE
wxBitmap dstBmp(w, h, srcBmp.GetDepth());
#if defined(__WXMSW__) || defined(__WXOSX__)
// wxBitmap::UseAlpha() is used only on wxMSW and wxOSX.
dstBmp.UseAlpha(srcBmp.HasAlpha());
#endif // __WXMSW__ || __WXOSX__
{
wxMemoryDC dc(dstBmp);
dc.SetUserScale(scaleX, scaleY);
dc.DrawBitmap(srcBmp, 0, 0);
}
#endif // wxUSE_IMAGE/!wxUSE_IMAGE
return dstBmp;
}
// -----------------------------------------------------------------------
wxPGProperty* wxPropertyGrid::DoGetItemAtY( int y ) const
{
// Outside?