Changeset 13723 in josm for trunk


Ignore:
Timestamp:
2018-05-10T22:25:39+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #16201 - Simplify calculation of SVG size in ImageProvider (patch by floscher)

File:
1 edited

Legend:

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

    r13653 r13723  
    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
     
    15661566            Logging.trace("createImageFromSvg: {0} {1}", svg.getXMLBase(), dim);
    15671567        }
    1568         float sourceWidth = svg.getWidth();
    1569         float sourceHeight = svg.getHeight();
    1570         int realWidth = Math.round(GuiSizesHelper.getSizeDpiAdjusted(sourceWidth));
    1571         int realHeight = Math.round(GuiSizesHelper.getSizeDpiAdjusted(sourceHeight));
    1572         Double scaleX, scaleY;
    1573         if (dim.width != -1) {
     1568        final float sourceWidth = svg.getWidth();
     1569        final float sourceHeight = svg.getHeight();
     1570        final int realWidth;
     1571        final int realHeight;
     1572        if (dim.width >= 0) {
    15741573            realWidth = dim.width;
    1575             scaleX = (double) realWidth / sourceWidth;
    1576             if (dim.height == -1) {
    1577                 scaleY = scaleX;
    1578                 realHeight = (int) Math.round(sourceHeight * scaleY);
     1574            if (dim.height >= 0) {
     1575                realHeight = dim.height;
    15791576            } else {
    1580                 realHeight = dim.height;
    1581                 scaleY = (double) realHeight / sourceHeight;
    1582             }
    1583         } else if (dim.height != -1) {
     1577                realHeight = Math.round(sourceHeight * realWidth / sourceWidth);
     1578            }
     1579        } else if (dim.height >= 0) {
    15841580            realHeight = dim.height;
    1585             scaleX = scaleY = (double) realHeight / sourceHeight;
    1586             realWidth = (int) Math.round(sourceWidth * scaleX);
     1581            realWidth = Math.round(sourceWidth * realHeight / sourceHeight);
    15871582        } else {
    1588             scaleX = scaleY = (double) realHeight / sourceHeight;
    1589         }
     1583            realWidth = Math.round(GuiSizesHelper.getSizeDpiAdjusted(sourceWidth));
     1584            realHeight = Math.round(GuiSizesHelper.getSizeDpiAdjusted(sourceHeight));
     1585        }
     1586        final Double scaleX = (double) realWidth / sourceWidth;
     1587        final Double scaleY = (double) realHeight / sourceHeight;
    15901588
    15911589        if (realWidth == 0 || realHeight == 0) {
Note: See TracChangeset for help on using the changeset viewer.