Changeset 19948 in osm


Ignore:
Timestamp:
2010-02-09T19:27:41+01:00 (14 years ago)
Author:
clementm
Message:

VectorImageModifier modifications:

  • Remove apparently useless code as makeTransparent and replaceColors are exclusive.
  • Corrected invertGrey + makeTransparent issues (grey colors could become transparent).
File:
1 edited

Legend:

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

    r18544 r19948  
    1616    public static int cadastreBackgroundTransp = 1; // original white but transparent
    1717
    18     private boolean withBackground = false;
    19 
    2018    private int backgroundPixel = 0;
    21 
    22     private int backgroundSampleX, backgroundSampleY;
    2319
    2420    public VectorImageModifier(BufferedImage bi) {
     
    4440                if (pixel == cadastreBackground) {
    4541                    bufferedImage.setRGB(x, y, josmBackgroundColor);
    46                     if (!withBackground)
    47                         withBackground = true;
    48                     backgroundSampleX = x;
    49                     backgroundSampleY = y;
    5042                }
    5143            }
    5244        }
     45        // The cadastre has now a new background (for invertGrey())
     46        cadastreBackground = josmBackgroundColor;
    5347    }
    5448
     
    8175        int b = col.getBlue();
    8276        if ((b == r) && (b == g)) {
    83             pixel = (0x00 << 32) + ((byte) (255 - r) << 16) + ((byte) (255 - r) << 8) + ((byte) (255 - r));
     77            pixel = ((byte) col.getAlpha() << 24) + ((byte) (255 - r) << 16) + ((byte) (255 - r) << 8) + ((byte) (255 - r));
    8478        }
     79        // Maybe we should try to find a better formula to avoid discontinuity when text is drawn on a colored item
     80        // (building, ...). One could use the conversion to and from HSB to only change the brightness not the color.
     81        // Note: the color palette does not have the inverse colors so it may be very weird!
    8582        return pixel;
    8683    }
     
    9390            WritableRaster raster = bufferedImage.getRaster();
    9491            // pixel is offset in ICM's palette
    95             if (withBackground)
    96                 backgroundPixel = raster.getSample(backgroundSampleX, backgroundSampleY, 0);
    97             else
    98                 backgroundPixel = 1; // default Cadastre background sample
     92            backgroundPixel = 1; // default Cadastre background sample
    9993            int size = icm.getMapSize();
    10094            byte[] reds = new byte[size];
     
    10498            icm.getGreens(greens);
    10599            icm.getBlues(blues);
     100            // The cadastre background has now an alpha to 0 (for invertGrey())
     101            cadastreBackground = 0x00ffffff;
    106102            IndexColorModel icm2 = new IndexColorModel(colorModel.getPixelSize(), size, reds, greens, blues,
    107103                    backgroundPixel);
Note: See TracChangeset for help on using the changeset viewer.