commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chtom...@apache.org
Subject [33/50] [abbrv] commons-imaging git commit: Match XPM color names case insensitively.
Date Wed, 24 May 2017 18:41:21 GMT
Match XPM color names case insensitively.

Patch by: me


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/imaging/trunk@1780731 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/commons-imaging/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-imaging/commit/104b4095
Tree: http://git-wip-us.apache.org/repos/asf/commons-imaging/tree/104b4095
Diff: http://git-wip-us.apache.org/repos/asf/commons-imaging/diff/104b4095

Branch: refs/heads/master
Commit: 104b40953929ac7d672427008e111c6c721639ab
Parents: 316d61d
Author: Damjan Jovanovic <damjan@apache.org>
Authored: Sat Jan 28 18:41:17 2017 +0000
Committer: Damjan Jovanovic <damjan@apache.org>
Committed: Sat Jan 28 18:41:17 2017 +0000

----------------------------------------------------------------------
 .../apache/commons/imaging/formats/xpm/XpmImageParser.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/104b4095/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
index e3b19fd..26bcff0 100644
--- a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
@@ -36,6 +36,7 @@ import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
@@ -91,7 +92,7 @@ public class XpmImageParser extends ImageParser {
                             final int green = Integer.parseInt(line.substring(4, 7).trim());
                             final int blue = Integer.parseInt(line.substring(8, 11).trim());
                             final String colorName = line.substring(11).trim();
-                            colors.put(colorName, 0xff000000 | (red << 16)
+                            colors.put(colorName.toLowerCase(Locale.ENGLISH), 0xff000000
| (red << 16)
                                     | (green << 8) | blue);
                         } catch (final NumberFormatException nfe) {
                             throw new ImageReadException("Couldn't parse color in rgb.txt",
nfe);
@@ -353,8 +354,9 @@ public class XpmImageParser extends ImageParser {
             return 0x00000000;
         } else {
             loadColorNames();
-            if (colorNames.containsKey(color)) {
-                return colorNames.get(color);
+            final String colorLowercase = color.toLowerCase(Locale.ENGLISH);
+            if (colorNames.containsKey(colorLowercase)) {
+                return colorNames.get(colorLowercase);
             }
             return 0x00000000;
         }


Mime
View raw message