diff options
author | Tor Lillqvist <tml@collabora.com> | 2022-02-02 16:29:34 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-02-03 14:43:53 +0100 |
commit | 266e6b76763d16bcb1dcf67bab2478a7d2d7b8fc (patch) | |
tree | d302a3de54a36bbfc074c73a4eda860463d1c8d7 /sd | |
parent | 6b14014342a665268b822729d465e9d3a3a2ca57 (diff) |
Make inserted or pasted PDF sharper on macOS
When inserting a PDF file as an image or pasting PDF data from the
clipboard on a Retina iMac the resulting rendered image did not look
sharp.
Using a surprisingly large extra scaling factor helps. The exact
reasons for this are unknown. It isn't enough to use a scaling factor
of just 2 (which is the HiDI ("Retina") scale factor on my iMac).
Possibly the fuzziness is related to what Pdfium uses to render text.
Also, look at CountDPIScaleFactor() in vcl/source/window/window.cxx.
The GetDPIScaleFactor() function lies on macOS even more than it does
on other platforms. It claims that the DPI scale percentage is always
100. But in fact most Macs nowadays have a Retina display so it would
make more sense, in theory, to at least always return 200 instead.
That wouldn't be any more wrong. But that causes regressions in the UI
rendering, like needlessly large icons in the toolbars.
Change-Id: Idc694f742c4ac32a5a134f8d206cf4eee467c39a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129369
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/view/sdview4.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index 80a653b7b9c8..5b7d5387d2c8 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -30,6 +30,8 @@ #include <sfx2/fcontnr.hxx> #include <sfx2/docfile.hxx> #include <sfx2/sfxsids.hrc> +#include <vcl/outdev.hxx> +#include <vcl/pdfread.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <svx/svdpagv.hxx> @@ -197,6 +199,10 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, } sal_Int32 nPreferredDPI = mrDoc.getImagePreferredDPI(); + + if (rGraphic.GetGfxLink().GetType() == GfxLinkType::NativePdf && nPreferredDPI == 0 && vcl::PDF_INSERT_MAGIC_SCALE_FACTOR > 1) + nPreferredDPI = Application::GetDefaultDevice()->GetDPIX() * vcl::PDF_INSERT_MAGIC_SCALE_FACTOR; + if (nPreferredDPI > 0) { auto nWidth = o3tl::convert(aSizePixel.Width() / double(nPreferredDPI), o3tl::Length::in, o3tl::Length::mm100); |