Changeset 16978 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-08-30T09:46:47+02:00 (4 years ago)
Author:
simon04
Message:

fix #19706, fix #19725 - Do not upscale images when using ImageResizeMode.BOUNDED

File:
1 edited

Legend:

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

    r16946 r16978  
    3535            CheckParameterUtil.ensureThat((dim.width > 0 || dim.width == -1) && (dim.height > 0 || dim.height == -1),
    3636                    () -> dim + " is invalid");
     37            final int maxWidth = Math.min(dim.width, icon.width);
     38            final int maxHeight = Math.min(dim.height, icon.height);
    3739            final Dimension spec;
    38             if (dim.width == -1 || dim.height == -1) {
     40            if (maxWidth == -1 || maxHeight == -1) {
    3941                spec = dim;
    40             } else if (icon.getWidth() / dim.width > icon.getHeight() / dim.height) {
    41                 spec = new Dimension(dim.width, -1);
     42            } else if (icon.getWidth() / maxWidth > icon.getHeight() / maxHeight) {
     43                spec = new Dimension(maxWidth, -1);
    4244            } else {
    43                 spec = new Dimension(-1, dim.height);
     45                spec = new Dimension(-1, maxHeight);
    4446            }
    4547            return AUTO.computeDimension(spec, icon);
    46             // TODO disable upscaling non-svg icons?
    4748        }
    4849    },
Note: See TracChangeset for help on using the changeset viewer.