Changeset 12723 in josm for trunk/src


Ignore:
Timestamp:
2017-09-04T19:22:41+02:00 (7 years ago)
Author:
bastiK
Message:

see #9995 - fix double scaling with gui.scale Einstein option (change extracted from a patch by strump)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageResource.java

    r12722 r12723  
    5959    public ImageResource(Image img) {
    6060        CheckParameterUtil.ensureParameterNotNull(img);
    61         baseImage = scaleBaseImageIfNeeded(img);
    62     }
    63 
    64     /** Scale image according to screen DPI if needed.
    65      *
    66      * @param img an image loaded from file (it's width and height are virtual pixels)
    67      * @return original img if virtual size is the same as real size or new image resized to real pixels
    68      */
    69     private static Image scaleBaseImageIfNeeded(Image img) {
    70         int imgWidth = img.getWidth(null);
    71         int imgHeight = img.getHeight(null);
    72         int realWidth = GuiSizesHelper.getSizeDpiAdjusted(imgWidth);
    73         int realHeight = GuiSizesHelper.getSizeDpiAdjusted(imgHeight);
    74         if (realWidth != -1 && realHeight != -1 && imgWidth != realWidth && imgHeight != realHeight) {
    75             Image realImage = img.getScaledInstance(realWidth, realHeight, Image.SCALE_SMOOTH);
    76             BufferedImage bimg = new BufferedImage(realWidth, realHeight, BufferedImage.TYPE_INT_ARGB);
    77             bimg.getGraphics().drawImage(realImage, 0, 0, null);
    78             return bimg;
    79         }
    80         return img;
     61        baseImage = img;
    8162    }
    8263
     
    162143        return getImageIcon(dim, true);
    163144    }
    164    
     145
    165146    /**
    166147     * Get an ImageIcon object for the image of this resource.
     
    229210            } catch (NoClassDefFoundError e) {
    230211                return new ImageIcon(img);
    231             } 
     212            }
    232213        }
    233214    }
Note: See TracChangeset for help on using the changeset viewer.