Changeset 7313 in josm
- Timestamp:
- 2014-07-16T00:46:30+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r7248 r7313 59 59 import org.openstreetmap.josm.Main; 60 60 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 61 import org.openstreetmap.josm.io.CachedFile; 61 62 import org.openstreetmap.josm.plugins.PluginHandler; 62 63 import org.w3c.dom.Element; … … 74 75 import com.kitfox.svg.SVGException; 75 76 import com.kitfox.svg.SVGUniverse; 76 import org.openstreetmap.josm.io.CachedFile;77 77 78 78 /** … … 1264 1264 */ 1265 1265 public static Color getTransparentColor(ImageReader reader) throws IOException { 1266 IIOMetadata metadata = reader.getImageMetadata(0); 1267 if (metadata != null) { 1268 String[] formats = metadata.getMetadataFormatNames(); 1269 if (formats != null) { 1270 for (String f : formats) { 1271 if ("javax_imageio_1.0".equals(f)) { 1272 Node root = metadata.getAsTree(f); 1273 if (root instanceof Element) { 1274 NodeList list = ((Element)root).getElementsByTagName("TransparentColor"); 1275 if (list.getLength() > 0) { 1276 Node item = list.item(0); 1277 if (item instanceof Element) { 1278 String value = ((Element)item).getAttribute("value"); 1279 String[] s = value.split(" "); 1280 if (s.length == 3) { 1281 int[] rgb = new int[3]; 1282 try { 1283 for (int i = 0; i<3; i++) { 1284 rgb[i] = Integer.parseInt(s[i]); 1266 try { 1267 IIOMetadata metadata = reader.getImageMetadata(0); 1268 if (metadata != null) { 1269 String[] formats = metadata.getMetadataFormatNames(); 1270 if (formats != null) { 1271 for (String f : formats) { 1272 if ("javax_imageio_1.0".equals(f)) { 1273 Node root = metadata.getAsTree(f); 1274 if (root instanceof Element) { 1275 NodeList list = ((Element)root).getElementsByTagName("TransparentColor"); 1276 if (list.getLength() > 0) { 1277 Node item = list.item(0); 1278 if (item instanceof Element) { 1279 String value = ((Element)item).getAttribute("value"); 1280 String[] s = value.split(" "); 1281 if (s.length == 3) { 1282 int[] rgb = new int[3]; 1283 try { 1284 for (int i = 0; i<3; i++) { 1285 rgb[i] = Integer.parseInt(s[i]); 1286 } 1287 return new Color(rgb[0], rgb[1], rgb[2]); 1288 } catch (IllegalArgumentException e) { 1289 Main.error(e); 1285 1290 } 1286 return new Color(rgb[0], rgb[1], rgb[2]);1287 } catch (IllegalArgumentException e) {1288 Main.error(e);1289 1291 } 1290 } 1292 } 1293 } 1291 1294 } 1292 }1295 break; 1293 1296 } 1294 break;1295 1297 } 1296 1298 } 1297 1299 } 1300 } catch (IIOException e) { 1301 // JAI doesn't like some JPEG files with error "Inconsistent metadata read from stream" (see #10267) 1302 Main.warn(e); 1298 1303 } 1299 1304 return null;
Note:
See TracChangeset
for help on using the changeset viewer.