List of utility methods to do Color to Hex
String | toHexString(Color color) to Hex String String hexaWith8Digits = Integer.toHexString(color.getRGB()); return new StringBuilder("#").append(hexaWith8Digits.substring(2, hexaWith8Digits.length())).toString(); |
String | toHexString(final Color aColor) Returns the given color instance as a string in the form of RR GG BB in which RR, GG, BB are the hexadecimal representations of red, green and blue. final StringBuilder sb = new StringBuilder(); sb.append(String.format("%02x", Integer.valueOf(aColor.getRed()))); sb.append(String.format("%02x", Integer.valueOf(aColor.getGreen()))); sb.append(String.format("%02x", Integer.valueOf(aColor.getBlue()))); return sb.toString(); |
String | toHexString(java.awt.Color c) Convert the given color to is string hex representation return "#" + padRight(Integer.toHexString(c.getRed()), 2, "0") + padRight(Integer.toHexString(c.getGreen()), 2, "0") + padRight(Integer.toHexString(c.getBlue()), 2, "0"); |
String | toHexString(java.awt.Color c) to Hex String return toHexString(c.getRGB());
|
String | toHexString(java.awt.Color colour) to Hex String String hexColour = Integer.toHexString(colour.getRGB() & 0xffffff); if (hexColour.length() < 6) { hexColour = "000000".substring(0, 6 - hexColour.length()) + hexColour; return "#" + hexColour; |