Fix wxSearchCtrl (generic) compilation when wxUSE_IMAGE==0
Implemented function to rescale a bitmap even if rescaling using wxImage is not possible.
This commit is contained in:
@@ -935,6 +935,32 @@ static int GetMultiplier()
|
|||||||
return 6;
|
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 )
|
wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop )
|
||||||
{
|
{
|
||||||
wxColour bg = GetBackgroundColour();
|
wxColour bg = GetBackgroundColour();
|
||||||
@@ -1027,9 +1053,7 @@ wxBitmap wxSearchCtrl::RenderSearchBitmap( int x, int y, bool renderDrop )
|
|||||||
|
|
||||||
if ( multiplier != 1 )
|
if ( multiplier != 1 )
|
||||||
{
|
{
|
||||||
wxImage image = bitmap.ConvertToImage();
|
RescaleBitmap(bitmap, wxSize(x, y));
|
||||||
image.Rescale(x,y);
|
|
||||||
bitmap = wxBitmap( image );
|
|
||||||
}
|
}
|
||||||
if ( !renderDrop )
|
if ( !renderDrop )
|
||||||
{
|
{
|
||||||
@@ -1117,9 +1141,7 @@ wxBitmap wxSearchCtrl::RenderCancelBitmap( int x, int y )
|
|||||||
|
|
||||||
if ( multiplier != 1 )
|
if ( multiplier != 1 )
|
||||||
{
|
{
|
||||||
wxImage image = bitmap.ConvertToImage();
|
RescaleBitmap(bitmap, wxSize(x, y));
|
||||||
image.Rescale(x,y);
|
|
||||||
bitmap = wxBitmap( image );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
Reference in New Issue
Block a user