Changeset 7495 in josm for trunk


Ignore:
Timestamp:
2014-09-05T00:14:59+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #10479 - proper handling of transparent files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r7402 r7495  
    680680            BufferedImage img = null;
    681681            try {
    682                 img = read(path, false, false);
     682                // See #10479: for PNG files, always enforce transparency to be sure tNRS chunk is used even not in paletted mode
     683                // This can be removed if someday Oracle fixes https://bugs.openjdk.java.net/browse/JDK-6788458
     684                // hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/828c4fedd29f/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java#l656
     685                img = read(path, false, true);
     686                if (Main.isDebugEnabled() && isTransparencyForced(img)) {
     687                    Main.debug("Transparency has been forced for image "+path.toExternalForm());
     688                }
    683689            } catch (IOException e) {
    684690                Main.warn(e);
     
    12401246                    bi = new BufferedImage(bi.getColorModel(), bi.getRaster(), bi.isAlphaPremultiplied(), properties);
    12411247                    if (enforceTransparency) {
    1242                         if (Main.isDebugEnabled()) {
    1243                             Main.debug("Enforcing image transparency of "+stream+" for "+color);
     1248                        if (Main.isTraceEnabled()) {
     1249                            Main.trace("Enforcing image transparency of "+stream+" for "+color);
    12441250                        }
    12451251                        bi = makeImageTransparent(bi, color);
     
    13201326    public static BufferedImage makeImageTransparent(BufferedImage bi, Color color) {
    13211327        // the color we are looking for. Alpha bits are set to opaque
    1322         final int markerRGB = color.getRGB() | 0xFFFFFFFF;
     1328        final int markerRGB = color.getRGB() | 0xFF000000;
    13231329        ImageFilter filter = new RGBImageFilter() {
    13241330            @Override
Note: See TracChangeset for help on using the changeset viewer.