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

intRGBToInt(float[] rgb)
RGB To Int
byte[] argb = { (byte) 0xFF, (byte) (rgb[0] * 0xFF), (byte) (rgb[1] * 0xFF), (byte) (rgb[2] * 0xFF) };
return (argb[0] << 24) + ((argb[1] & 0xFF) << 16) + ((argb[2] & 0xFF) << 8) + (argb[3] & 0xFF);
intRGBtoInt(int r, int g, int b)
Converts RGB values to an RGB integer value.
return (256 * 256 * r + 256 * g + b);
intRGBtoInt(int red, int green, int blue)
RG Bto Int
return 255 << 24 | red << 16 | +green << 8 | blue;
intRGBtoInt(String rgb)
RG Bto Int
int r = Integer.parseInt(getR(rgb), 16);
int g = Integer.parseInt(getG(rgb), 16);
int b = Integer.parseInt(getB(rgb), 16);
int clr = r;
clr = clr << 8 | g;
clr = clr << 8 | b;
return clr;
intRGBToInteger(int red, int green, int blue)
Converts representation of color in RGB model in triplet (r, g, b) to single number in hexadecimal system.
return 0x00000000 | (red << 16) | (green << 8) | blue;
shortrgbToShort(int rgb)
Converts a 24 bit RGB value to a 15 bit RGB value.
return (short) (((rgb & 0xf8) >> 3) | ((rgb & 0xf800) >> 6) | ((rgb & 0xf80000) >> 9));
StringrgbToString(float r, float g, float b)
rgb To String
String rs = Integer.toHexString((int) (r * 256));
String gs = Integer.toHexString((int) (g * 256));
String bs = Integer.toHexString((int) (b * 256));
return "#" + rs + gs + bs;
StringrgbToText(int red, int green, int blue)
Converts a color's RGB presentation to a textual hexadecimal representation.
return String.format("#%02x%02x%02x", red, green, blue);
voidrgbToUnscaledYUV(int[][] rgb)
rgb To Unscaled YUV
int length = rgb[0].length;
final int[] rs = rgb[0];
final int[] gs = rgb[1];
final int[] bs = rgb[2];
for (int i = 0; i < length; i++) {
    int r = rs[i];
    int g = gs[i];
    int b = bs[i];
...
float[]RGBtoXYZ(float r, float g, float b)
RG Bto XYZ
float x = 0.412453f * r + 0.357580f * g + 0.180423f * b;
float y = 0.212671f * r + 0.715160f * g + 0.072169f * b;
float z = 0.019334f * r + 0.119193f * g + 0.950227f * b;
return new float[] { x, y, z };