Changeset 16978 in josm for trunk/src/org/openstreetmap
- Timestamp:
 - 2020-08-30T09:46:47+02:00 (5 years ago)
 - File:
 - 
      
- 1 edited
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
trunk/src/org/openstreetmap/josm/tools/ImageResizeMode.java
r16946 r16978 35 35 CheckParameterUtil.ensureThat((dim.width > 0 || dim.width == -1) && (dim.height > 0 || dim.height == -1), 36 36 () -> dim + " is invalid"); 37 final int maxWidth = Math.min(dim.width, icon.width); 38 final int maxHeight = Math.min(dim.height, icon.height); 37 39 final Dimension spec; 38 if ( dim.width == -1 ||dim.height == -1) {40 if (maxWidth == -1 || maxHeight == -1) { 39 41 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); 42 44 } else { 43 spec = new Dimension(-1, dim.height);45 spec = new Dimension(-1, maxHeight); 44 46 } 45 47 return AUTO.computeDimension(spec, icon); 46 // TODO disable upscaling non-svg icons?47 48 } 48 49 },  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  