Changeset 13823 in josm


Ignore:
Timestamp:
2018-05-23T20:22:13+02:00 (7 years ago)
Author:
Don-vip
Message:

see #9984, see #16047 - Java 11 handles transparent PNG out of the box, disable JOSM mechanisms to force transparency on this version

Location:
trunk
Files:
2 edited

Legend:

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

    r13737 r13823  
    17781778     * @param enforceTransparency if {@code true}, makes sure to read image metadata and, if the image does not
    17791779     * provide an alpha channel but defines a {@code TransparentColor} metadata node, that the resulting image
    1780      * has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color.
     1780     * has a transparency set to {@code TRANSLUCENT} and uses the correct transparent color. For Java < 11 only.
    17811781     *
    17821782     * @return a <code>BufferedImage</code> containing the decoded
     
    18011801        try {
    18021802            bi = reader.read(0, param);
    1803             if (bi.getTransparency() != Transparency.TRANSLUCENT && (readMetadata || enforceTransparency)) {
     1803            if (bi.getTransparency() != Transparency.TRANSLUCENT && (readMetadata || enforceTransparency) && Utils.getJavaVersion() < 11) {
    18041804                Color color = getTransparentColor(bi.getColorModel(), reader);
    18051805                if (color != null) {
  • trunk/test/unit/org/openstreetmap/josm/tools/ImageProviderTest.java

    r11526 r13823  
    6464        assertEquals(Transparency.TRANSLUCENT, ImageProvider.read(file, true, true).getTransparency());
    6565        assertEquals(Transparency.TRANSLUCENT, ImageProvider.read(file, false, true).getTransparency());
    66         assertEquals(Transparency.OPAQUE, ImageProvider.read(file, false, false).getTransparency());
    67         assertEquals(Transparency.OPAQUE, ImageProvider.read(file, true, false).getTransparency());
     66        long expectedTransparency = Utils.getJavaVersion() < 11 ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
     67        assertEquals(expectedTransparency, ImageProvider.read(file, false, false).getTransparency());
     68        assertEquals(expectedTransparency, ImageProvider.read(file, true, false).getTransparency());
    6869    }
    6970
Note: See TracChangeset for help on using the changeset viewer.