intForHex
public static int intForHex(java.lang.String h)
Compute the rgb integer for a hex color.
The behavior of Color.decode is not well described.
Here's the experiment
// System.out.println("from 0xrrggbb: "+((Color.decode("0xEEFFFF").getRGB())&0xFFFFFF));
// System.out.println("from #rrggbb: "+((Color.decode("#EEFFFF").getRGB())&0xFFFFFF));
// System.out.println("from #rgb: "+((Color.decode("#EFF").getRGB())&0xFFFFFF)); // as if #FFF101 !!!
// System.out.println("from 0ccccccc: "+((Color.decode("073577777").getRGB())&0xFFFFFF));
// System.out.println("from dec: "+((Color.decode("15663103").getRGB())&0xFFFFFF));
// String h = "#EFF";
// char r = h.charAt(1), g = h.charAt(2), b = h.charAt(3);
// h = "#"+r+r+g+g+b+b;
// System.out.println("#rgb-<#rrggbb: " + h);
//
//// from 0xrrggbb: 15663103
//// from #rrggbb: 15663103
//// from #rgb: 3839
//// from 0ccccccc: 15663103
//// from dec: 15663103
//// #rgb-<#rrggbb: #EEFFFF
- Parameters:
h
- The hex string
- Returns:
- Corresponding integer value