diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-10-28 23:24:30 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2016-10-29 21:47:41 +0000 |
commit | 69b6ab1f8de08b3418fd42d56076a73d40a29229 (patch) | |
tree | b9d3ced7be6ab7c70388a91cd8b56b68d3651d07 /vcl/source/image | |
parent | a86144696df87cd81795e071a30b74af127c7948 (diff) |
tdf#100164 change scaling unit to precentage for *.5x factors
Currently we support DPI scaling by a integer factor. This commit
changes that to percentage so we can have scaling factors like
1.5x or 1.25x. This is useful with 2.7k monitors that are in
between standard DPI and HiDPI. Thresholding was adjusted to scale
to 1.5x when DPI is between 120 and 168 DPI.
The old method GetDPIScaleFactor has been changed to return a
float value insted of int. Sometimes it is however more accurate
to use GetDPIScalePercentage which was added in this commit.
Change-Id: Iaecee793ff3d5084d00adeebbcf5d7368c580882
Reviewed-on: https://gerrit.libreoffice.org/30379
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source/image')
-rw-r--r-- | vcl/source/image/ImplImageTree.cxx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx index a112ddb2bcb7..c101e5b7ed11 100644 --- a/vcl/source/image/ImplImageTree.cxx +++ b/vcl/source/image/ImplImageTree.cxx @@ -124,9 +124,9 @@ void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString con if (eFlags & ImageLoadFlags::IgnoreDarkTheme) bConvertToDarkTheme = false; - sal_Int32 aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor(); + float aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor(); if (eFlags & ImageLoadFlags::IgnoreScalingFactor) - aScaleFactor = 1; + aScaleFactor = 1.0f; if (rPath.endsWith(".png")) { @@ -149,7 +149,7 @@ void loadImageFromStream(std::shared_ptr<SvStream> const & xStream, OUString con if (bConvertToDarkTheme) rBitmap = BitmapProcessor::createLightImage(rBitmap); - if (aScaleFactor > 1) + if (aScaleFactor > 1.0f) rBitmap.Scale(double(aScaleFactor), double(aScaleFactor), BmpScaleFlag::Fast); } @@ -284,13 +284,15 @@ OUString createVariant(const ImageLoadFlags eFlags) if (eFlags & ImageLoadFlags::IgnoreDarkTheme) bConvertToDarkTheme = false; - sal_Int32 aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor(); + sal_Int32 aScalePercentage = Application::GetDefaultDevice()->GetDPIScalePercentage(); if (eFlags & ImageLoadFlags::IgnoreScalingFactor) - aScaleFactor = 1; + aScalePercentage = 100; OUString aVariant; - if (aScaleFactor == 2) - aVariant = "2x"; + if (aScalePercentage == 100 && !bConvertToDarkTheme) + return aVariant; + + aVariant = OUString::number(aScalePercentage); if (bConvertToDarkTheme) aVariant += "-dark"; |