Changeset 13737 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2018-05-13T01:39:07+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r13723 r13737 1568 1568 final float sourceWidth = svg.getWidth(); 1569 1569 final float sourceHeight = svg.getHeight(); 1570 final int realWidth;1571 final int realHeight;1570 final float realWidth; 1571 final float realHeight; 1572 1572 if (dim.width >= 0) { 1573 1573 realWidth = dim.width; … … 1575 1575 realHeight = dim.height; 1576 1576 } else { 1577 realHeight = Math.round(sourceHeight * realWidth / sourceWidth);1577 realHeight = sourceHeight * realWidth / sourceWidth; 1578 1578 } 1579 1579 } else if (dim.height >= 0) { 1580 1580 realHeight = dim.height; 1581 realWidth = Math.round(sourceWidth * realHeight / sourceHeight);1581 realWidth = sourceWidth * realHeight / sourceHeight; 1582 1582 } else { 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; 1583 realWidth = GuiSizesHelper.getSizeDpiAdjusted(sourceWidth); 1584 realHeight = GuiSizesHelper.getSizeDpiAdjusted(sourceHeight); 1585 } 1588 1586 1589 1587 if (realWidth == 0 || realHeight == 0) { 1590 1588 return null; 1591 1589 } 1592 BufferedImage img = new BufferedImage( realWidth, realHeight, BufferedImage.TYPE_INT_ARGB);1590 BufferedImage img = new BufferedImage(Math.round(realWidth), Math.round(realHeight), BufferedImage.TYPE_INT_ARGB); 1593 1591 Graphics2D g = img.createGraphics(); 1594 g.setClip(0, 0, realWidth, realHeight);1595 g.scale( scaleX, scaleY);1592 g.setClip(0, 0, img.getWidth(), img.getHeight()); 1593 g.scale(realWidth / sourceWidth, realHeight / sourceHeight); 1596 1594 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 1597 1595 try {
Note:
See TracChangeset
for help on using the changeset viewer.