Changeset 4961 in josm for trunk/src/org/openstreetmap/josm/tools/ImageResource.java
- Timestamp:
- 2012-02-16T21:21:17+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r4960 r4961 22 22 * Caches the image data for resized versions of the same image. 23 23 */ 24 private HashMap<Dimension, Image> imgCache = new HashMap<Dimension,Image>();24 private HashMap<Dimension, BufferedImage> imgCache = new HashMap<Dimension, BufferedImage>(); 25 25 private SVGDiagram svg; 26 26 public static final Dimension DEFAULT_DIMENSION = new Dimension(-1, -1); 27 27 28 public ImageResource( Image img) {28 public ImageResource(BufferedImage img) { 29 29 CheckParameterUtil.ensureParameterNotNull(img); 30 30 imgCache.put(DEFAULT_DIMENSION, img); … … 49 49 if (dim.width < -1 || dim.width == 0 || dim.height < -1 || dim.height == 0) 50 50 throw new IllegalArgumentException(); 51 Image img = imgCache.get(dim);51 BufferedImage img = imgCache.get(dim); 52 52 if (img != null) { 53 53 return new ImageIcon(img); … … 58 58 return new ImageIcon(img); 59 59 } else { 60 Image base = imgCache.get(DEFAULT_DIMENSION);60 BufferedImage base = imgCache.get(DEFAULT_DIMENSION); 61 61 if (base == null) throw new AssertionError(); 62 62 … … 69 69 height = icon.getIconHeight() * width / icon.getIconWidth(); 70 70 } 71 img = icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH); 71 Image i = icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH); 72 img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 73 img.getGraphics().drawImage(i, 0, 0, null); 72 74 imgCache.put(dim, img); 73 75 return new ImageIcon(img); … … 91 93 realHeight = svg.getHeight(); 92 94 } else { 93 Image base = imgCache.get(DEFAULT_DIMENSION);95 BufferedImage base = imgCache.get(DEFAULT_DIMENSION); 94 96 if (base == null) throw new AssertionError(); 95 97 ImageIcon icon = new ImageIcon(base);
Note:
See TracChangeset
for help on using the changeset viewer.