Changeset 17522 in osm for applications/editors/josm/plugins/wmsplugin
- Timestamp:
- 2009-09-08T17:22:29+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java
r17397 r17522 5 5 import java.awt.Image; 6 6 import java.awt.Point; 7 import java.awt.Toolkit;8 7 import java.awt.image.BufferedImage; 9 import java.awt.image.FilteredImageSource;10 import java.awt.image.ImageProducer;11 import java.awt.image.RGBImageFilter;12 8 import java.io.IOException; 13 9 import java.io.ObjectInputStream; … … 87 83 88 84 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 alpha90 // But we do get a black instead of white background.91 //Image ppImg = image;92 /*if(!alphaChannel) {93 // set alpha value to 25594 ppImg = clearAlpha(image);95 }*/96 85 97 86 try { … … 102 91 //System.out.println("Img Size: "+ (width*height*3/1024/1024) +" MB"); 103 92 93 int multipl = alphaChannel ? 4 : 3; 104 94 // This happens when requesting images while zoomed out and then zooming in 105 95 // Storing images this large in memory will certainly hang up JOSM. Luckily 106 96 // traditional rendering is as fast at these zoom levels, so it's no loss. 107 97 // 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) { 109 99 fallbackDraw(g, image, minPt, maxPt); 110 100 } else { … … 113 103 alphaChannel 114 104 ? BufferedImage.TYPE_INT_ARGB 115 : BufferedImage.TYPE_3BYTE_BGR // This removes alpha , too105 : BufferedImage.TYPE_3BYTE_BGR // This removes alpha 116 106 ); 117 107 reImg.getGraphics().drawImage(image, … … 165 155 } 166 156 167 private Image clearAlpha(Image img) {168 ImageProducer ip = img.getSource();169 RGBImageFilter filter = new RGBImageFilter() {170 @Override171 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 181 157 public void flushedResizedCachedInstance() { 182 158 reImg = null;
Note:
See TracChangeset
for help on using the changeset viewer.