Java Utililty Methods RGB Color Create

List of utility methods to do RGB Color Create

Description

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

Method

ImagenewRGBImage(int[] rgb, int width, int height, boolean processAlpha)
new RGB Image
if (rgb == null) {
    throw new NullPointerException();
if (width <= 0 || height <= 0) {
    throw new IllegalArgumentException();
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
if (!processAlpha) {
...
StringRGB(float R, float G, float B)
Constructs a color given 3 RGB values.
byte r = (byte) (255 * R);
byte g = (byte) (255 * G);
byte b = (byte) (255 * B);
return "#" + hd[r >> 4] + hd[r & 15] + hd[g >> 4] + hd[g & 15] + hd[b >> 4] + hd[b & 15];
intrgb(float rIn, float gIn, float bIn)
Makes an integer color from the given red, green, and blue float values
return rgb(floor(rIn * 255.0F), floor(gIn * 255.0F), floor(bIn * 255.0F));
intrgb(int a, int r, int g, int b)
rgb
int ret = 0;
ret |= (a & 0xff) << 24;
ret |= (r & 0xff) << 16;
ret |= (g & 0xff) << 8;
ret |= (b & 0xff) << 0;
return ret;
int[]rgb(int argb)
rgb
return new int[] { (argb >> 16) & 0xFF, (argb >> 8) & 0xFF, argb & 0xFF };
int[]rgb(int pixel)
rgb
int r = (pixel & 0xff0000) >> 16;
int g = (pixel & 0xff00) >> 8;
int b = (pixel & 0xff);
int[] m = { r, g, b };
return m;
intrgb(int r, int g, int b)
rgb
return (r << 16) + (g << 8) + b;
intrgb(int red, int green, int blue)
rgb
int color = 0;
color |= 0xFF000000;
color |= (red & 0xFF) << 16;
color |= (green & 0xFF) << 8;
color |= blue & 0xFF;
return color;
intRGB_GREEN(int rgb)
RGGREEN
return (((rgb) >> 8) & 0xff);
doubleRGB_MSE(int[] rgb1, int[] rgb2)
Calculate the mean square error of the two RGB data
if (rgb1.length != rgb2.length)
    throw new RuntimeException("The images need to have the same number of pixels");
double mse = 0;
for (int i = 0; i < rgb1.length; i++) {
    int a = rgb1[i];
    int b = rgb2[i];
    mse += sqr((a & 0xff) - (b & 0xff));
    mse += sqr(((a >> 8) & 0xff) - ((b >> 8) & 0xff));
...