Changeset 8723 in josm for trunk/src/org
- Timestamp:
- 2015-09-03T16:57:32+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r8715 r8723 208 208 tile.setImage(null); 209 209 } 210 if (sharpenLevel != 0 && success) {211 tile.setImage(sharpenImage(tile.getImage()));212 }213 210 tile.setLoaded(success); 214 211 needRedraw = true; -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r8625 r8723 75 75 protected double dy = 0.0; 76 76 77 protected int sharpenLevel;78 79 77 private final ImageryAdjustAction adjustAction = new ImageryAdjustAction(this); 80 78 … … 93 91 icon = ImageProvider.get("imagery_small"); 94 92 } 95 this.sharpenLevel = PROP_SHARPEN_LEVEL.get();93 addImageProcessor(createSharpener(PROP_SHARPEN_LEVEL.get())); 96 94 } 97 95 … … 238 236 } 239 237 240 public BufferedImage sharpenImage(BufferedImage img) { 241 if (sharpenLevel <= 0) return img; 242 int width = img.getWidth(null); 243 int height = img.getHeight(null); 244 BufferedImage tmp = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 245 tmp.getGraphics().drawImage(img, 0, 0, null); 246 Kernel kernel; 238 public ImageProcessor createSharpener(int sharpenLevel) { 239 final Kernel kernel; 247 240 if (sharpenLevel == 1) { 248 kernel = new Kernel(3, 3, new float[] {-0.25f, -0.5f, -0.25f, -0.5f, 4, -0.5f, -0.25f, -0.5f, -0.25f}); 241 kernel = new Kernel(3, 3, new float[]{-0.25f, -0.5f, -0.25f, -0.5f, 4, -0.5f, -0.25f, -0.5f, -0.25f}); 242 } else if (sharpenLevel == 2) { 243 kernel = new Kernel(3, 3, new float[]{-0.5f, -1, -0.5f, -1, 7, -1, -0.5f, -1, -0.5f}); 249 244 } else { 250 kernel = new Kernel(3, 3, new float[] {-0.5f, -1, -0.5f, -1, 7, -1, -0.5f, -1, -0.5f});245 return null; 251 246 } 252 247 BufferedImageOp op = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); 253 return op.filter(tmp, null);254 } 255 256 /** 257 * This method adds the {@link ImageProcessor} to this Layer 248 return createImageProcessor(op, false); 249 } 250 251 /** 252 * This method adds the {@link ImageProcessor} to this Layer if it is not {@code null}. 258 253 * 259 254 * @param processor that processes the image … … 262 257 */ 263 258 public boolean addImageProcessor(ImageProcessor processor) { 264 return imageProcessors.add(processor);259 return processor != null && imageProcessors.add(processor); 265 260 } 266 261 … … 274 269 public boolean removeImageProcessor(ImageProcessor processor) { 275 270 return imageProcessors.remove(processor); 271 } 272 273 /** 274 * Wraps a {@link BufferedImageOp} to be used as {@link ImageProcessor}. 275 * @param op the {@link BufferedImageOp} 276 * @param inPlace true to apply filter in place, i.e., not create a new {@link BufferedImage} for the result 277 * (the {@code op} needs to support this!) 278 * @return the {@link ImageProcessor} wrapper 279 */ 280 public static ImageProcessor createImageProcessor(final BufferedImageOp op, final boolean inPlace) { 281 return new ImageProcessor() { 282 @Override 283 public BufferedImage process(BufferedImage image) { 284 return op.filter(image, inPlace ? image : null); 285 } 286 }; 276 287 } 277 288 -
trunk/src/org/openstreetmap/josm/tools/ImageOverlay.java
r8722 r8723 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import org.openstreetmap.josm.gui.layer.ImageProcessor; 3 5 4 6 import java.awt.Dimension; … … 10 12 * @since 8095 11 13 */ 12 public class ImageOverlay {14 public class ImageOverlay implements ImageProcessor { 13 15 /** the image resource to use as overlay */ 14 16 public ImageProvider image; … … 65 67 * @since 8095 66 68 */ 67 public BufferedImage apply(BufferedImage ground) { 69 @Override 70 public BufferedImage process(BufferedImage ground) { 68 71 /* get base dimensions for calculation */ 69 72 int w = ground.getWidth(); -
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r8095 r8723 115 115 if (overlayInfo != null) { 116 116 for (ImageOverlay o : overlayInfo) { 117 o. apply(bimg);117 o.process(bimg); 118 118 } 119 119 } … … 139 139 if (overlayInfo != null) { 140 140 for (ImageOverlay o : overlayInfo) { 141 o. apply(bimg);141 o.process(bimg); 142 142 } 143 143 }
Note:
See TracChangeset
for help on using the changeset viewer.