diff options
author | Hossein <hossein@libreoffice.org> | 2021-11-19 22:39:10 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-11-20 07:13:14 +0100 |
commit | aadb472a6d37d57279f91038f28047af4278bbbc (patch) | |
tree | 8fb788d1705ae91698e6cf6ac93b42f0d458c460 /extensions | |
parent | 23886b0e023bc27e9ba89f9ab6d1bdf36da022ab (diff) |
Use o3tl::convert
Used o3tl::convert on nXRes and nYRes to calculate biXPelsPerMeter
and biYPelsPerMeter for the bitmap information header structure pBIH:
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader
The values of biXPelsPerMeter and biYPelsPerMeter are always ignored
by the GDI when loading the bitmaps, but in theory they can be
recommendations for the pysical size of a bitmap in some applications.
https://devblogs.microsoft.com/oldnewthing/20130515-00/?p=4363
Change-Id: Ia40f17b7d1c27c094158af89bf15ed2f11bdfc05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125109
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/scanner/twain32shim.cxx | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/extensions/source/scanner/twain32shim.cxx b/extensions/source/scanner/twain32shim.cxx index eab704fcb8db..254ed747281d 100644 --- a/extensions/source/scanner/twain32shim.cxx +++ b/extensions/source/scanner/twain32shim.cxx @@ -30,6 +30,7 @@ #include "twain32shim.hxx" #include <tools/helpers.hxx> #include <twain/twain.h> +#include <o3tl/unit_conversion.hxx> #define WM_TWAIN_FALLBACK (WM_SHIM_INTERNAL + 0) @@ -416,10 +417,11 @@ void ImpTwain::ImplXfer() { // set resolution of bitmap BITMAPINFOHEADER* pBIH = static_cast<BITMAPINFOHEADER*>(pBmpMem); - static const double fFactor = 100.0 / 2.54; - pBIH->biXPelsPerMeter = FRound(fFactor * nXRes); - pBIH->biYPelsPerMeter = FRound(fFactor * nYRes); + static const auto[m, d] + = getConversionMulDiv(o3tl::Length::in, o3tl::Length::m); + pBIH->biXPelsPerMeter = o3tl::convert(nXRes, d, m); + pBIH->biYPelsPerMeter = o3tl::convert(nYRes, d, m); } HANDLE hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, |