- Timestamp:
- 2020-09-02T19:58:39+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r16997 r16998 1501 1501 Logging.log(Logging.LEVEL_ERROR, "Unable to load svg:", ex); 1502 1502 } 1503 } );1503 }, null); 1504 1504 } 1505 1505 -
trunk/src/org/openstreetmap/josm/tools/ImageResizeMode.java
r16997 r16998 4 4 import java.awt.Dimension; 5 5 import java.awt.Graphics2D; 6 import java.awt.Image; 6 7 import java.awt.RenderingHints; 7 8 import java.awt.image.BufferedImage; … … 87 88 * @param icon the dimensions of the image to resize 88 89 * @param renderer the rendering function 90 * @param sourceIcon the source icon to draw 89 91 * @return a new buffered image 90 92 */ 91 BufferedImage createBufferedImage(Dimension dim, Dimension icon, Consumer<Graphics2D> renderer ) {93 BufferedImage createBufferedImage(Dimension dim, Dimension icon, Consumer<Graphics2D> renderer, Image sourceIcon) { 92 94 final Dimension real = computeDimension(dim, icon); 93 95 final BufferedImage bufferedImage = new BufferedImage(real.width, real.height, BufferedImage.TYPE_INT_ARGB); 94 96 final Graphics2D g = bufferedImage.createGraphics(); 95 97 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 96 prepareGraphics(icon, bufferedImage, g); 97 renderer.accept(g); 98 if (renderer != null) { 99 prepareGraphics(icon, bufferedImage, g); 100 renderer.accept(g); 101 } else if (sourceIcon != null) { 102 sourceIcon = sourceIcon.getScaledInstance(real.width, real.height, Image.SCALE_SMOOTH); 103 g.drawImage(sourceIcon, 0, 0, null); 104 } else { 105 throw new NullPointerException("renderer or sourceIcon"); 106 } 98 107 return bufferedImage; 99 108 } -
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r16946 r16998 187 187 ImageIcon icon = new ImageIcon(baseImage); 188 188 img = resizeMode.createBufferedImage(dim, new Dimension(icon.getIconWidth(), icon.getIconHeight()), 189 g -> g.drawImage(icon.getImage(), 0, 0, null));189 null, icon.getImage()); 190 190 } 191 191 if (overlayInfo != null) {
Note:
See TracChangeset
for help on using the changeset viewer.