diff --git a/src/msw/bmpbndl.cpp b/src/msw/bmpbndl.cpp index f5ec7b25dd..6ecd42a78e 100644 --- a/src/msw/bmpbndl.cpp +++ b/src/msw/bmpbndl.cpp @@ -191,48 +191,14 @@ wxSize wxBitmapBundleImplRC::GetDefaultSize() const wxSize wxBitmapBundleImplRC::GetPreferredBitmapSizeAtScale(double scale) const { - // Optimistically assume we're going to use this exact scale by default. - double scalePreferred = scale; - - for ( size_t i = 0; ; ++i ) + const size_t n = m_resourceInfos.size(); + wxVector scales(n); + for ( size_t i = 0; i < n; ++i ) { - if ( i == m_resourceInfos.size() ) - { - // The requested scale is bigger than anything we have, so use the - // biggest available one. - scalePreferred = m_resourceInfos[i - 1].scale; - break; - } - - const double scaleThis = m_resourceInfos[i].scale; - - // Keep looking for the exact match which we still can hope to find - // while the current scale is smaller. - if ( scaleThis < scale ) - continue; - - // If we've found the exact match, just use it. - if ( scaleThis == scale ) - break; - - // We've found the closest bigger scale. - - // If there is no smaller one, we have no choice but to use this one. - if ( i == 0 ) - break; - - // Decide whether we should use this one or the previous smaller one - // depending on which of them is closer to the target scale, breaking - // the tie in favour of the bigger one. - const double scaleLast = m_resourceInfos[i - 1].scale; - - scalePreferred = scaleThis - scale <= scale - scaleLast - ? scaleThis - : scaleLast; - break; + scales[i] = m_resourceInfos[i].scale; } - return GetDefaultSize()*scalePreferred; + return DoGetPreferredSize(scale, n, &scales[0]); } wxBitmap