Java Utililty Methods Color Convert To

List of utility methods to do Color Convert To

Description

The list of methods to do Color Convert To are organized into topic(s).

Method

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;
StringcolorToHex(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();
...
StringcolorToHex(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);
intcolorToRGB(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;
...
StringcolorToString(int color, boolean rgb)
color To String
String result = null;
if (rgb) {
    result = "" + splitRed(color) + ", " + splitGreen(color) + ", " + splitBlue(color);
} else
    result = "" + color;
return result;
StringcolorToStringHex(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);