Ignore:
Timestamp:
2009-02-18T23:31:32+01:00 (16 years ago)
Author:
pieren
Message:

Fix minor bugs, add the fixed size grab scale configurable, fix pbls in transparency.

File:
1 edited

Legend:

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

    r13611 r13784  
    1818    public static final int cadastreBackground = -1; // white
    1919
     20    public static final int cadastreBackgroundTransp = 1; // original white but transparent
     21
    2022    public BufferedImage bufferedImage;
    2123
     
    2830    public ImageModifier(BufferedImage bi) {
    2931        bufferedImage = bi;
    30         if (Main.pref.getBoolean("cadastrewms.alterColors")) {
    31             changeColors();
    32             if (Main.pref.getBoolean("cadastrewms.backgroundTransparent")) {
    33                 makeTransparent();
    34             }
    35         }
     32        if (Main.pref.getBoolean("cadastrewms.backgroundTransparent"))
     33            makeTransparent();
     34        else if (Main.pref.getBoolean("cadastrewms.alterColors"))
     35            replaceBackground();
     36       
     37        if (Main.pref.getBoolean("cadastrewms.invertGrey"))
     38            invertGrey();
    3639    }
    3740
    3841    /**
    3942     * Replace the background color by the josm color.background color.
    40      * @param bi
    41      * @return
    4243     */
    43     private void changeColors() {
     44    private void replaceBackground() {
    4445        int w = bufferedImage.getWidth();
    4546        int h = bufferedImage.getHeight();
    46         int pixel;
    47         int josmBackgroundColor = ColorHelper.html2color(Main.pref.get("color.background", "#FFFFFF")).getRGB();
    48         boolean invertGrey = (Main.pref.getBoolean("cadastrewms.invertGrey"));
     47        int josmBackgroundColor = ColorHelper.html2color(Main.pref.get("color.background", "#000000")).getRGB();
    4948        for (int x = 0; x < w; x++) {
    5049            for (int y = 0; y < h; y++) {
    51                 pixel = bufferedImage.getRGB(x, y);
     50                int pixel = bufferedImage.getRGB(x, y);
    5251                if (pixel == cadastreBackground) {
    5352                    bufferedImage.setRGB(x, y, josmBackgroundColor);
     
    5655                    backgroundSampleX = x;
    5756                    backgroundSampleY = y;
    58                 } else if (invertGrey) {
     57                }
     58            }
     59        }
     60    }
     61   
     62    /**
     63     * Invert black/white/grey pixels (to change original black characters to white).
     64     */
     65    private void invertGrey() {
     66        int w = bufferedImage.getWidth();
     67        int h = bufferedImage.getHeight();
     68        for (int x = 0; x < w; x++) {
     69            for (int y = 0; y < h; y++) {
     70                int pixel = bufferedImage.getRGB(x, y);
     71                if (pixel != cadastreBackground) {
    5972                    bufferedImage.setRGB(x, y, reverseIfGrey(pixel));
    6073                }
     
    6275        }
    6376    }
    64    
     77
    6578    /**
    6679     * Reverse the grey value if the pixel is grey (light grey becomes dark grey)
Note: See TracChangeset for help on using the changeset viewer.