Ignore:
Timestamp:
2009-09-08T17:22:29+02:00 (15 years ago)
Author:
stoecker
Message:

fix josm bug 2752 - patch by xeen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java

    r17397 r17522  
    55import java.awt.Image;
    66import java.awt.Point;
    7 import java.awt.Toolkit;
    87import java.awt.image.BufferedImage;
    9 import java.awt.image.FilteredImageSource;
    10 import java.awt.image.ImageProducer;
    11 import java.awt.image.RGBImageFilter;
    128import java.io.IOException;
    139import java.io.ObjectInputStream;
     
    8783
    8884        boolean alphaChannel = Main.pref.getBoolean("wmsplugin.alpha_channel");
    89         // We don't need this, as simply saving the image to RGB instead of ARGB removes alpha
    90         // But we do get a black instead of white background.
    91         //Image ppImg = image;
    92         /*if(!alphaChannel) {
    93             // set alpha value to 255
    94             ppImg = clearAlpha(image);
    95         }*/
    9685
    9786        try {
     
    10291            //System.out.println("Img Size:              "+ (width*height*3/1024/1024) +" MB");
    10392
     93            int multipl = alphaChannel ? 4 : 3;
    10494            // This happens when requesting images while zoomed out and then zooming in
    10595            // Storing images this large in memory will certainly hang up JOSM. Luckily
    10696            // traditional rendering is as fast at these zoom levels, so it's no loss.
    10797            // Also prevent caching if we're out of memory soon
    108             if(width > 10000 || height > 10000 || width*height*3 > freeMem) {
     98            if(width > 2000 || height > 2000 || width*height*multipl > freeMem) {
    10999                fallbackDraw(g, image, minPt, maxPt);
    110100            } else {
     
    113103                    alphaChannel
    114104                        ? BufferedImage.TYPE_INT_ARGB
    115                         : BufferedImage.TYPE_3BYTE_BGR  // This removes alpha, too
     105                        : BufferedImage.TYPE_3BYTE_BGR  // This removes alpha
    116106                    );
    117107                reImg.getGraphics().drawImage(image,
     
    165155    }
    166156
    167     private Image clearAlpha(Image img) {
    168         ImageProducer ip = img.getSource();
    169         RGBImageFilter filter = new RGBImageFilter() {
    170                 @Override
    171             public int filterRGB(int x, int y, int rgb) {
    172                 return rgb | 0xff000000;
    173             }
    174         };
    175         ImageProducer filt_ip = new FilteredImageSource(ip, filter);
    176         Image out_img = Toolkit.getDefaultToolkit().createImage(filt_ip);
    177 
    178         return out_img;
    179     }
    180 
    181157    public void flushedResizedCachedInstance() {
    182158        reImg = null;
Note: See TracChangeset for help on using the changeset viewer.