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

intconvertRgb888To565(int rgb888)
Converts an RGB 888 color to RGB 565 color space.
return ((rgb888 & 0xf80000) >> 8) | ((rgb888 & 0xfc00) >> 5) | ((rgb888 & 0xf8) >> 3);
intconvertRgbaToArgb(int rgba)
Returns the converted value.
return (rgba >>> 8) | (rgba << (32 - 8));
byte[]convertRgbToByteArray(int[] rgb)
Converts the given int[] RGB array into a byte[] array without preserving the alpa channel (each RGB pixel is in the format 0xAARRGGBB).
return convertRgbToByteArray(rgb, 0, rgb.length);
float[]convertRGBtoHSL(int r, int g, int b)
Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and lightness that are the three components of the HSL model.
float varR = (r / 255f);
float varG = (g / 255f);
float varB = (b / 255f);
float varMin = Math.min(varR, Math.min(varG, varB)); 
float varMax = Math.max(varR, Math.max(varG, varB)); 
float delMax = varMax - varMin; 
float h = 0;
float s = 0;
...
voidconvertRGBtoHSV(float[] rgb, float[] hsv)
Change an RGB color to HSV color.
convertRGBtoHSV(rgb[0], rgb[1], rgb[2], hsv);
voidconvertRGBtoYIQ(float[] rgb, float[] yiq)
Change an RGB color to YIQ (JPEG) color.
float r = rgb[0];
float g = rgb[1];
float b = rgb[2];
yiq[0] = (0.299900f * r) + (0.587000f * g) + (0.114000f * b);
yiq[1] = (0.595716f * r) - (0.274453f * g) - (0.321264f * b);
yiq[2] = (0.211456f * r) - (0.522591f * g) + (0.311350f * b);
float[]rgb24FloatArray(float[] array, int rgb24)
rgb Float Array
assert array.length == 3;
array[0] = (float) (rgb24 >> 16 & 255) / 255.0F;
array[1] = (float) (rgb24 >> 8 & 255) / 255.0F;
array[2] = (float) (rgb24 & 255) / 255.0F;
return array;
voidrgb2arr(final int color, final int[] argbarr)
rgbarr
argbarr[0] = (color & 0x00ff0000) >> 16;
argbarr[1] = (color & 0x0000ff00) >> 8;
argbarr[2] = (color & 0x000000ff);
byte[]rgb2bilevel(int[] rgb)
rgbbilevel
byte[] pixels = new byte[rgb.length];
int sum = 0;
for (int i = 0; i < rgb.length; i++) {
    if ((rgb[i] >>> 24) < 0x80)
        pixels[i] = (byte) 0xff; 
    else
        pixels[i] = (byte) (((rgb[i] >> 16) & 0xff) * 0.2126 + ((rgb[i] >> 8) & 0xff) * 0.7152
                + (rgb[i] & 0xff) * 0.0722);
...
doublergb2gray(int r, int g, int b)
rgbgray
return 0.3 * r + 0.59 * g + 0.11 * b;