Changeset 19949 in osm for applications


Ignore:
Timestamp:
2010-02-09T19:42:26+01:00 (15 years ago)
Author:
clementm
Message:

WMSLayer image drawing filtering options:

  • Nearest Neighbor = Default, fastest : poor readability if zooming out
  • Bilinear, fast : good readability if low resolution, blury if zooming in
  • Bicubic, slow: best readability when zooming out, good readability if zooming in
Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java

    r19894 r19949  
    3535
    3636    private JCheckBox drawBoundaries = new JCheckBox(tr("Draw boundaries of downloaded data."));
     37
     38    private JComboBox imageInterpolationMethod = new JComboBox();
    3739
    3840    private JCheckBox disableImageCropping = new JCheckBox(tr("Disable image cropping during georeferencing."));
     
    121123        drawBoundaries.setToolTipText(tr("Draw a rectangle around downloaded data from WMS server."));
    122124        cadastrewms.add(drawBoundaries, GBC.eop().insets(0, 0, 0, 5));
     125
     126        // option to select image zooming interpolation method
     127        JLabel jLabelImageZoomInterpolation = new JLabel(tr("Image zoom interpolation:"));
     128        cadastrewms.add(jLabelImageZoomInterpolation, GBC.std().insets(0, 0, 10, 0));
     129        imageInterpolationMethod.addItem(tr("Nearest-Neighbor (fastest) [ Default ]"));
     130        imageInterpolationMethod.addItem(tr("Bilinear (fast)"));
     131        imageInterpolationMethod.addItem(tr("Bicubic (slow)"));
     132        String savedImageInterpolationMethod = Main.pref.get("cadastrewms.imageInterpolation", "standard");
     133        if (savedImageInterpolationMethod.equals("bilinear"))
     134            imageInterpolationMethod.setSelectedIndex(1);
     135        else if (savedImageInterpolationMethod.equals("bicubic"))
     136            imageInterpolationMethod.setSelectedIndex(2);
     137        else
     138            imageInterpolationMethod.setSelectedIndex(0);
     139        cadastrewms.add(imageInterpolationMethod, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
    123140
    124141        // separator
     
    242259        Main.pref.put("cadastrewms.brightness", Float.toString((float)sliderTrans.getValue()/10));
    243260        Main.pref.put("cadastrewms.drawBoundaries", drawBoundaries.isSelected());
     261        if (imageInterpolationMethod.getSelectedIndex() == 2)
     262            Main.pref.put("cadastrewms.imageInterpolation", "bicubic");
     263        else if (imageInterpolationMethod.getSelectedIndex() == 1)
     264            Main.pref.put("cadastrewms.imageInterpolation", "bilinear");
     265        else
     266            Main.pref.put("cadastrewms.imageInterpolation", "standard");
    244267        if (grabMultiplier1.isSelected())
    245268            Main.pref.put("cadastrewms.scale", Scale.X1.toString());
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r19702 r19949  
    1010import java.awt.Image;
    1111import java.awt.Point;
     12import java.awt.RenderingHints;
    1213import java.awt.Toolkit;
    1314import java.awt.image.BufferedImage;
     
    234235    public void paint(Graphics2D g, final MapView mv, Bounds bounds) {
    235236        synchronized(this){
     237            Object savedInterpolation = g.getRenderingHint(RenderingHints.KEY_INTERPOLATION);
     238            if (savedInterpolation == null) savedInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
     239            String interpolation = Main.pref.get("cadastrewms.imageInterpolation", "Standard");
     240            if (interpolation.equals("bilinear"))
     241                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
     242            else if (interpolation.equals("bicubic"))
     243                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
     244            else
     245                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
    236246            for (GeorefImage img : images)
    237247                img.paint(g, mv, CadastrePlugin.backgroundTransparent,
    238248                        CadastrePlugin.transparency, CadastrePlugin.drawBoundaries);
     249            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, savedInterpolation);
    239250        }
    240251        if (this.isRaster) {
Note: See TracChangeset for help on using the changeset viewer.