Allow tweaking parameters of wxImage::Scale() benchmarks

Use the string parameter as the name of the file containing the image to
resize and the numeric parameter as the scale factor in percents (so
that fractional factors could also be specified using this integer
parameter).
This commit is contained in:
Vadim Zeitlin 2022-02-22 23:59:36 +00:00
parent a8ec7eec0b
commit e25b47ee32

View File

@ -65,7 +65,7 @@ static const wxImage& GetTestImage()
if ( !s_triedToLoad )
{
s_triedToLoad = true;
s_image.LoadFile("horse.bmp");
s_image.LoadFile(Bench::GetStringParameter("horse.bmp"));
}
return s_image;
@ -73,20 +73,32 @@ static const wxImage& GetTestImage()
BENCHMARK_FUNC(EnlargeNormal)
{
return GetTestImage().Scale(300, 300, wxIMAGE_QUALITY_NORMAL).IsOk();
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(150) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_NORMAL).IsOk();
}
BENCHMARK_FUNC(EnlargeHighQuality)
{
return GetTestImage().Scale(300, 300, wxIMAGE_QUALITY_HIGH).IsOk();
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(150) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_HIGH).IsOk();
}
BENCHMARK_FUNC(ShrinkNormal)
{
return GetTestImage().Scale(50, 50, wxIMAGE_QUALITY_NORMAL).IsOk();
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(50) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_NORMAL).IsOk();
}
BENCHMARK_FUNC(ShrinkHighQuality)
{
return GetTestImage().Scale(50, 50, wxIMAGE_QUALITY_HIGH).IsOk();
const wxImage& image = GetTestImage();
const double factor = Bench::GetNumericParameter(50) / 100.;
return image.Scale(factor*image.GetWidth(), factor*image.GetHeight(),
wxIMAGE_QUALITY_HIGH).IsOk();
}