Ignore:
Timestamp:
2012-02-16T21:21:17+01:00 (12 years ago)
Author:
stoecker
Message:

see #1576 - switch ImageResource complete to BufferedImage, fix last accidential checkin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageResource.java

    r4960 r4961  
    2222     * Caches the image data for resized versions of the same image.
    2323     */
    24     private HashMap<Dimension, Image> imgCache = new HashMap<Dimension, Image>();
     24    private HashMap<Dimension, BufferedImage> imgCache = new HashMap<Dimension, BufferedImage>();
    2525    private SVGDiagram svg;
    2626    public static final Dimension DEFAULT_DIMENSION = new Dimension(-1, -1);
    2727 
    28     public ImageResource(Image img) {
     28    public ImageResource(BufferedImage img) {
    2929        CheckParameterUtil.ensureParameterNotNull(img);
    3030        imgCache.put(DEFAULT_DIMENSION, img);
     
    4949        if (dim.width < -1 || dim.width == 0 || dim.height < -1 || dim.height == 0)
    5050            throw new IllegalArgumentException();
    51         Image img = imgCache.get(dim);
     51        BufferedImage img = imgCache.get(dim);
    5252        if (img != null) {
    5353            return new ImageIcon(img);
     
    5858            return new ImageIcon(img);
    5959        } else {
    60             Image base = imgCache.get(DEFAULT_DIMENSION);
     60            BufferedImage base = imgCache.get(DEFAULT_DIMENSION);
    6161            if (base == null) throw new AssertionError();
    6262           
     
    6969                height = icon.getIconHeight() * width / icon.getIconWidth();
    7070            }
    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);
    7274            imgCache.put(dim, img);
    7375            return new ImageIcon(img);
     
    9193            realHeight = svg.getHeight();
    9294        } else {
    93             Image base = imgCache.get(DEFAULT_DIMENSION);
     95            BufferedImage base = imgCache.get(DEFAULT_DIMENSION);
    9496            if (base == null) throw new AssertionError();
    9597            ImageIcon icon = new ImageIcon(base);
Note: See TracChangeset for help on using the changeset viewer.