Changeset 13129 in josm for trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
- Timestamp:
- 2017-11-19T19:07:47+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r13127 r13129 617 617 * implementation, which adds support for HiDPI displays. The effect will be 618 618 * that in HiDPI mode, when GUI elements are scaled by a factor 1.5, 2.0, etc., 619 * the images are not just up-scaled, but a higher resolution version of the 620 * image is rendered instead. 619 * the images are not just up-scaled, but a higher resolution version of the image is rendered instead. 621 620 * <p> 622 * Use {@link HiDPISupport#getBaseImage(java.awt.Image)} to extract the original 623 * image from a multi-resolution image. 621 * Use {@link HiDPISupport#getBaseImage(java.awt.Image)} to extract the original image from a multi-resolution image. 624 622 * <p> 625 * See {@link HiDPISupport#processMRImage} for how to process the image without 626 * removing the multi-resolution magic. 623 * See {@link HiDPISupport#processMRImage} for how to process the image without removing the multi-resolution magic. 627 624 * @param multiResolution true, if multi-resolution image is requested 628 625 * @return the current object, for convenience … … 821 818 // This method is called from different thread and modifying HashMap concurrently can result 822 819 // for example in loops in map entries (ie freeze when such entry is retrieved) 823 // Yes, it did happen to me :-)824 820 if (name == null) 825 821 return null; … … 911 907 // and redundant when you have a whole ton of objects. So, 912 908 // index the cache by the name of the icon we're looking for 913 // and don't bother to create a URL unless we're actually 914 // creating the image. 909 // and don't bother to create a URL unless we're actually creating the image. 915 910 URL path = getImageUrl(fullName); 916 911 if (path == null) { … … 1618 1613 * has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color. 1619 1614 * 1620 * @return a <code>BufferedImage</code> containing the decoded 1621 * contents of the input, or <code>null</code>. 1615 * @return a <code>BufferedImage</code> containing the decoded contents of the input, or <code>null</code>. 1622 1616 * 1623 1617 * @throws IllegalArgumentException if <code>input</code> is <code>null</code>. … … 1673 1667 * has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color. 1674 1668 * 1675 * @return a <code>BufferedImage</code> containing the decoded 1676 * contents of the input, or <code>null</code>. 1669 * @return a <code>BufferedImage</code> containing the decoded contents of the input, or <code>null</code>. 1677 1670 * 1678 1671 * @throws IllegalArgumentException if <code>input</code> is <code>null</code>. … … 1717 1710 * has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color. 1718 1711 * 1719 * @return a <code>BufferedImage</code> containing the decoded 1720 * contents of the input, or <code>null</code>. 1712 * @return a <code>BufferedImage</code> containing the decoded contents of the input, or <code>null</code>. 1721 1713 * 1722 1714 * @throws IllegalArgumentException if <code>input</code> is <code>null</code>. … … 1987 1979 public static BufferedImage toBufferedImage(Image image, Rectangle crop_area) { 1988 1980 BufferedImage buffImage = null; 1989 1990 1981 Rectangle r = new Rectangle(image.getWidth(null), image.getHeight(null)); 1991 1982 if (r.intersection(crop_area).equals(crop_area)) { 1992 1983 buffImage = new BufferedImage(crop_area.width, crop_area.height, BufferedImage.TYPE_INT_ARGB); 1993 1984 Graphics2D g2 = buffImage.createGraphics(); 1994 g2.drawImage(image, 1995 0, 0, crop_area.width, crop_area.height, 1996 crop_area.x, crop_area.y, 1997 crop_area.x + crop_area.width, crop_area.y + crop_area.height, 1998 null); 1985 g2.drawImage(image, 0, 0, crop_area.width, crop_area.height, 1986 crop_area.x, crop_area.y, crop_area.x + crop_area.width, crop_area.y + crop_area.height, null); 1999 1987 g2.dispose(); 2000 1988 }
Note:
See TracChangeset
for help on using the changeset viewer.