Changeset 323 in josm


Ignore:
Timestamp:
2007-09-16T04:37:42+02:00 (17 years ago)
Author:
framm
Message:
  • fixed GeoImageLayer to release memory after thubmnails are built. This was always the intended behavoour but did not work properly, leading to memory shortage when working with large/many images.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java

    r319 r323  
    1010import java.awt.Cursor;
    1111import java.awt.Graphics;
     12import java.awt.Graphics2D;
    1213import java.awt.GridBagLayout;
    1314import java.awt.Image;
     
    2021import java.awt.event.MouseEvent;
    2122import java.awt.event.KeyEvent;
     23import java.awt.image.BufferedImage;
    2224import java.io.File;
    2325import java.io.IOException;
     
    509511                        h = maxSize;
    510512                }
    511                 return new ImageIcon(img.getScaledInstance(w, h, Image.SCALE_SMOOTH));
     513                return new ImageIcon(createResizedCopy(img, w, h));
     514        }
     515       
     516        private static BufferedImage createResizedCopy(Image originalImage,
     517                        int scaledWidth, int scaledHeight)
     518        {
     519                BufferedImage scaledBI = new BufferedImage(scaledWidth, scaledHeight, BufferedImage.TYPE_INT_RGB);
     520                Graphics2D g = scaledBI.createGraphics();
     521
     522                g.drawImage(originalImage, 0, 0, scaledWidth, scaledHeight, null);
     523                g.dispose();
     524                return scaledBI;
    512525        }
    513526}
Note: See TracChangeset for help on using the changeset viewer.