Changeset 13784 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java
- Timestamp:
- 2009-02-18T23:31:32+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java
r13611 r13784 18 18 public static final int cadastreBackground = -1; // white 19 19 20 public static final int cadastreBackgroundTransp = 1; // original white but transparent 21 20 22 public BufferedImage bufferedImage; 21 23 … … 28 30 public ImageModifier(BufferedImage bi) { 29 31 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(); 36 39 } 37 40 38 41 /** 39 42 * Replace the background color by the josm color.background color. 40 * @param bi41 * @return42 43 */ 43 private void changeColors() {44 private void replaceBackground() { 44 45 int w = bufferedImage.getWidth(); 45 46 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(); 49 48 for (int x = 0; x < w; x++) { 50 49 for (int y = 0; y < h; y++) { 51 pixel = bufferedImage.getRGB(x, y);50 int pixel = bufferedImage.getRGB(x, y); 52 51 if (pixel == cadastreBackground) { 53 52 bufferedImage.setRGB(x, y, josmBackgroundColor); … … 56 55 backgroundSampleX = x; 57 56 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) { 59 72 bufferedImage.setRGB(x, y, reverseIfGrey(pixel)); 60 73 } … … 62 75 } 63 76 } 64 77 65 78 /** 66 79 * Reverse the grey value if the pixel is grey (light grey becomes dark grey)
Note:
See TracChangeset
for help on using the changeset viewer.