Ignore:
Timestamp:
2010-03-09T22:02:00+01:00 (14 years ago)
Author:
pieren
Message:

Many small fixes and improvements

File:
1 edited

Legend:

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

    r20247 r20390  
    33package cadastre_fr;
    44
     5import java.awt.Color;
    56import java.awt.Transparency;
    67import java.awt.image.BufferedImage;
     
    1718    private static final long serialVersionUID = 1L;
    1819
     20    protected int parcelColor = Color.RED.getRGB();
     21   
    1922    public BufferedImage bufferedImage;
     23
     24    public static int[] cRoofColors = new int[] {-197380, -592138};
     25    public static int[] cBuilingFootColors = new int[] {-256};
    2026
    2127    protected BufferedImage convert1(BufferedImage src) {
     
    107113        return dest;
    108114      }
     115
     116    public boolean isBuildingColor(int rgb, boolean ignoreParcelColor) {
     117        for (int i = 0; i < cBuilingFootColors.length; i++)
     118            if (rgb == cBuilingFootColors[i])
     119                    return true;
     120        if (ignoreParcelColor && (rgb == parcelColor))
     121            return true;
     122        return false;
     123    }
     124
     125    public boolean isRoofColor(int rgb, boolean ignoreParcelColor) {
     126        for (int i = 0; i < cRoofColors.length; i++)
     127            if (rgb == cRoofColors[i])
     128                    return true;
     129        if (ignoreParcelColor && (rgb == parcelColor))
     130            return true;
     131        return false;
     132    }
     133
     134    public boolean isBuildingOrRoofColor(BufferedImage img, int x, int y, boolean ignoreParcelColor) {
     135        int rgb = img.getRGB(x, y);
     136        boolean ret = isBuildingColor(rgb, ignoreParcelColor) || isRoofColor(rgb, ignoreParcelColor);
     137        return ret;
     138    }
     139
     140    public boolean isBuildingOrRoofColor(BufferedImage img, int x, int y, boolean colorType, boolean ignoreParcelColor) {
     141        int rgb = img.getRGB(x, y);
     142        boolean ret;
     143        if (colorType)
     144            ret = isBuildingColor(rgb, ignoreParcelColor);
     145        else
     146            ret = isRoofColor(rgb, ignoreParcelColor);
     147        return ret;
     148    }
     149
     150    /**
     151     * Checks if the rgb value is the black background color
     152     * @param 
     153     * @return
     154     */
     155    public boolean isBackgroundColor(BufferedImage img, int x, int y) {
     156        return (img.getRGB(x, y) == -1);
     157    }
     158
    109159}
Note: See TracChangeset for help on using the changeset viewer.