List of utility methods to do Color Convert To
float[] | colorToFloat(int color) color To Float float[] c = new float[4]; c[3] = (color >> 24 & 0xff) / 255.0f; c[0] = (color >> 16 & 0xff) / 255.0f; c[1] = (color >> 8 & 0xff) / 255.0f; c[2] = (color >> 0 & 0xff) / 255.0f; return c; |
String | colorToHex(int color) color To Hex StringBuilder hexBuilder = new StringBuilder(6); hexBuilder.setLength(6); for (int i = 5; i >= 0; i--) { int j = color & 0x0F; hexBuilder.setCharAt(i, hexDigits[j]); color >>= 4; return hexBuilder.toString(); ... |
String | colorToHex(int integer) Convert an integer representing a color scale to 2 hex digits. if (integer > 255) { throw new IllegalArgumentException("Color value cannot be great than 255"); if (integer > 15) { return Integer.toHexString(integer); return "0" + Integer.toHexString(integer); |
int | colorToRGB(final int alpha, final int red, final int green, final int blue) color To RGB int newPixel = 0;
newPixel += alpha;
newPixel = newPixel << 8;
newPixel += red;
newPixel = newPixel << 8;
newPixel += green;
newPixel = newPixel << 8;
newPixel += blue;
...
|
String | colorToString(int color, boolean rgb) color To String String result = null; if (rgb) { result = "" + splitRed(color) + ", " + splitGreen(color) + ", " + splitBlue(color); } else result = "" + color; return result; |
String | colorToStringHex(int red, int green, int blue) color To String Hex return Integer.toHexString(0xF & red >> 4) + Integer.toHexString(0x0F & red)
+ Integer.toHexString(0xF & green >> 4) + Integer.toHexString(0x0F & green)
+ Integer.toHexString(0xF & blue >> 4) + Integer.toHexString(0x0F & blue);
|