Ticket #20035: hidpi-geoimage.patch

File hidpi-geoimage.patch, 2.5 KB (added by *Martin*, 5 years ago)

patch

  • src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java

    diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java b/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
    index 9e1075028..c983338fd 100644
    a b import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent;  
    3535import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
    3636import org.openstreetmap.josm.tools.Destroyable;
    3737import org.openstreetmap.josm.tools.ExifReader;
     38import org.openstreetmap.josm.tools.HiDPISupport;
    3839import org.openstreetmap.josm.tools.ImageProvider;
    3940import org.openstreetmap.josm.tools.Logging;
    4041
    public class ImageDisplay extends JComponent implements Destroyable, PreferenceC  
    774775                    if (bi != null) {
    775776                        r.x = r.y = 0;
    776777
     778                        double s = HiDPISupport.getHiDPIScale();
     779
    777780                        // See https://community.oracle.com/docs/DOC-983611 - The Perils of Image.getScaledInstance()
    778781                        // Pre-scale image when downscaling by more than two times to avoid aliasing from default algorithm
    779                         bi = ImageProvider.createScaledImage(bi, target.width, target.height,
     782                        bi = ImageProvider.createScaledImage(bi, (int) (target.width * s), (int) (target.height * s),
    780783                                RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    781                         r.width = target.width;
    782                         r.height = target.height;
     784                        r.width = (int) (target.width * s);
     785                        r.height = (int) (target.height * s);
     786
    783787                        image = bi;
    784788                    }
    785789                } catch (OutOfMemoryError oom) {
  • src/org/openstreetmap/josm/tools/HiDPISupport.java

    diff --git a/src/org/openstreetmap/josm/tools/HiDPISupport.java b/src/org/openstreetmap/josm/tools/HiDPISupport.java
    index b84e5879e..e187fd53f 100644
    a b public final class HiDPISupport {  
    175175     * only take the default screen device into account.
    176176     * @return the GUI scale for HiDPI mode, a value of 1.0 means standard mode.
    177177     */
    178     static double getHiDPIScale() {
     178    public static double getHiDPIScale() {
    179179        if (GraphicsEnvironment.isHeadless())
    180180            return 1.0;
    181181        GraphicsConfiguration gc = GraphicsEnvironment