diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 25e8107cdf..a0a5e3336f 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -935,6 +935,32 @@ static int GetMultiplier() return 6; } +static void RescaleBitmap(wxBitmap& bmp, const wxSize& sizeNeeded) +{ + wxCHECK_RET( sizeNeeded.IsFullySpecified(), wxS("New size must be given") ); + +#if wxUSE_IMAGE + wxImage img = bmp.ConvertToImage(); + img.Rescale(sizeNeeded.x, sizeNeeded.y); + bmp = wxBitmap(img); +#else // !wxUSE_IMAGE + // Fallback method of scaling the bitmap + wxBitmap newBmp(sizeNeeded); +#if defined(__WXMSW__) || defined(__WXOSX__) + // wxBitmap::UseAlpha() is used only on wxMSW and wxOSX. + newBmp.UseAlpha(bmp.HasAlpha()); +#endif // __WXMSW__ || __WXOSX__ + { + wxMemoryDC dc(newBmp); + double scX = (double)sizeNeeded.GetWidth() / bmp.GetWidth(); + double scY = (double)sizeNeeded.GetHeight() / bmp.GetHeight(); + dc.SetUserScale(scX, scY); + dc.DrawBitmap(bmp, 0, 0); + } + bmp = newBmp; +#endif // wxUSE_IMAGE/!wxUSE_IMAGE +} + wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop ) { wxColour bg = GetBackgroundColour(); @@ -1027,9 +1053,7 @@ wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop ) if ( multiplier != 1 ) { - wxImage image = bitmap.ConvertToImage(); - image.Rescale(x,y); - bitmap = wxBitmap( image ); + RescaleBitmap(bitmap, wxSize(x, y)); } if ( !renderDrop ) { @@ -1117,9 +1141,7 @@ wxBitmap wxSearchCtrl::RenderCancelBitmap( int x, int y ) if ( multiplier != 1 ) { - wxImage image = bitmap.ConvertToImage(); - image.Rescale(x,y); - bitmap = wxBitmap( image ); + RescaleBitmap(bitmap, wxSize(x, y)); } return bitmap;