Ticket #16201: ImageProvider-SVG-scaling.patch

File ImageProvider-SVG-scaling.patch, 2.7 KB (added by floscher, 7 years ago)
  • src/org/openstreetmap/josm/tools/ImageProvider.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    166166         * Splash dialog logo size
    167167         * @since 10358
    168168         */
    169         SPLASH_LOGO(128, 129),
     169        SPLASH_LOGO(128, 128),
    170170        /**
    171171         * About dialog logo size
    172172         * @since 10358
    173173         */
    174         ABOUT_LOGO(256, 258),
     174        ABOUT_LOGO(256, 256),
    175175        /**
    176176         * Status line logo size
    177177         * @since 13369
     
    15371537        if (Logging.isTraceEnabled()) {
    15381538            Logging.trace("createImageFromSvg: {0} {1}", svg.getXMLBase(), dim);
    15391539        }
    1540         float sourceWidth = svg.getWidth();
    1541         float sourceHeight = svg.getHeight();
    1542         int realWidth = Math.round(GuiSizesHelper.getSizeDpiAdjusted(sourceWidth));
    1543         int realHeight = Math.round(GuiSizesHelper.getSizeDpiAdjusted(sourceHeight));
    1544         Double scaleX, scaleY;
    1545         if (dim.width != -1) {
     1540        final float sourceWidth = svg.getWidth();
     1541        final float sourceHeight = svg.getHeight();
     1542        final int realWidth;
     1543        final int realHeight;
     1544        if (dim.width >= 0) {
    15461545            realWidth = dim.width;
    1547             scaleX = (double) realWidth / sourceWidth;
    1548             if (dim.height == -1) {
    1549                 scaleY = scaleX;
    1550                 realHeight = (int) Math.round(sourceHeight * scaleY);
    1551             } else {
     1546            if (dim.height >= 0) {
    15521547                realHeight = dim.height;
    1553                 scaleY = (double) realHeight / sourceHeight;
     1548            } else {
     1549                realHeight = Math.round(sourceHeight * realWidth / sourceWidth);
    15541550            }
    1555         } else if (dim.height != -1) {
     1551        } else if (dim.height >= 0) {
    15561552            realHeight = dim.height;
    1557             scaleX = scaleY = (double) realHeight / sourceHeight;
    1558             realWidth = (int) Math.round(sourceWidth * scaleX);
     1553            realWidth = Math.round(sourceWidth * realHeight / sourceHeight);
    15591554        } else {
    1560             scaleX = scaleY = (double) realHeight / sourceHeight;
     1555            realWidth = Math.round(GuiSizesHelper.getSizeDpiAdjusted(sourceWidth));
     1556            realHeight = Math.round(GuiSizesHelper.getSizeDpiAdjusted(sourceHeight));
    15611557        }
     1558        final Double scaleX = (double) realWidth / sourceWidth;
     1559        final Double scaleY = (double) realHeight / sourceHeight;
    15621560
    15631561        if (realWidth == 0 || realHeight == 0) {
    15641562            return null;