Java Utililty Methods RGB Color Convert To

List of utility methods to do RGB Color Convert To

Description

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

Method

intrgbToGray(int pixels)
rgb To Gray
int _red = (pixels >> 16) & 0xFF;
int _green = (pixels >> 8) & 0xFF;
int _blue = (pixels) & 0xFF;
return (int) (0.3 * _red + 0.59 * _green + 0.11 * _blue);
intRgbToGray(int r, int g, int b)
Rgb To Gray
return (int) (r * .3 + g * .59 + b * .11);
byte[]rgbToGrey(byte[] rgb)
Return a grey RGB triplet corresponding to the luminance of the incoming color RGB triplet.
byte[] g = new byte[3];
int lum = getRGBLum(rgb);
g[0] = g[1] = g[2] = (byte) lum;
return g;
StringrgbToHex(final int r, final int g, final int b)
RGB to hex based in this
final StringBuilder sb = new StringBuilder();
sb.append('#').append(Integer.toHexString(r)).append(Integer.toHexString(g)).append(Integer.toHexString(b));
return sb.toString();
StringrgbToHex(int r, int g, int b)
rgb To Hex
String sr = Integer.toHexString(r);
String sg = Integer.toHexString(g);
String sb = Integer.toHexString(b);
if (sr.length() < 2)
    sr = "0" + sr;
if (sg.length() < 2)
    sg = "0" + sg;
if (sb.length() < 2)
...
StringRGBtoHex(int r, int g, int b)
RG Bto Hex
String val = Integer.toHexString(r << 16 | g << 8 | b);
while (val.length() < 6)
    val = "0" + val;
return val;
StringrgbToHex(int[] rgb)
rgb To Hex
return String.format("%02x%02x%02x", rgb[0], rgb[1], rgb[2]);
intRGBToHex(int[] rgb)
RGB To Hex
if (rgb.length < 3)
    return -1;
return ((rgb[0] << 16) | (rgb[1] << 8) | rgb[2]);
StringrgbToHex(String color)
rgb To Hex
String[] RGB = color.split(",");
return toHex(RGB[0]) + toHex(RGB[1]) + toHex(RGB[2]);
float[]RGBtoHSB(int r, int g, int b, float hsbvals[])
Convert from RGB to HSB color
if (hsbvals == null) {
    hsbvals = new float[3];
int l = r <= g ? g : r;
if (b > l) {
    l = b;
int i1 = r >= g ? g : r;
...