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

float[]cmykToRgb(float... cmyk)
cmyk To Rgb
if (cmyk.length != 4) {
    throw new IllegalArgumentException();
float[] fromRGB = iccInstance.toRGB(cmyk);
return fromRGB;
intdeformationToRGB(final double val, final double min, final double max)
deformation To RGB
final int result;
if (Double.isNaN(val)) {
    if (debugMode) {
        result = COLOR_NaN;
    } else {
        result = Color.HSBtoRGB(0, 1, 0);
} else {
...
ColorfromHtmlRGB(String rgb)
from Html RGB
int r = Integer.parseInt(rgb.substring(1, 3), 16);
int g = Integer.parseInt(rgb.substring(3, 5), 16);
int b = Integer.parseInt(rgb.substring(5, 7), 16);
return new Color(r, g, b);
ColorfromRGB(String tag)
Makes Color objects from the string specified according to [CSS2-color] Fixed currently supported: black|blue|cyan|darkGray|gray|green|lightGray|magenta|orange|pink|red|white|yellow or you can define as rgb format: #rrggbb
     color=color.black;
    else if(s.equals("blue")){
     color=color.blue;
    else if(s.equals("cyan")){
     color=color.cyan;
    else if(s.equals("darkGray")){
     color=color.darkGray;
    else if(s.equals("gray")){
     color=color.gray;
    else if(s.equals("green")){
     color=color.green;
    else if(s.equals("lightGray")){
     color=color.lightGray;
    else if(s.equals("magenta")){
     color=color.magenta;
    else if(s.equals("orange")){
     color=color.orange;
    else if(s.equals("pink")){
     color=color.pink;
    else if(s.equals("red")){
     color=color.red;
    else if(s.equals("white")){
     color=color.white;
    else if(s.equals("yellow")){
     color=color.yellow;
    return color;
    */
private static Color fromRGB(String tag) {
    Color color = null;
    try {
        String rgb = tag.substring(1);
        int r = Integer.parseInt(rgb.substring(0, 2), 16);
        int g = Integer.parseInt(rgb.substring(2, 4), 16);
        int b = Integer.parseInt(rgb.substring(4, 6), 16);
        return new Color(r, g, b);
    } catch (Exception e) {
    return color;
intgetRGB(Color color)
get RGB
return getRGB(color.getRed(), color.getGreen(), color.getBlue());
float[]getRGB(java.awt.Color color)
get RGB
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
float[] rgb = new float[] { (float) (r / 255.), (float) (g / 255.), (float) (b / 255.) };
return rgb;
ImagemakeIcon(int width, int height, int[] rgb)
make Icon
BufferedImage i = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
i.setRGB(0, 0, width, height, rgb, 0, width);
return i;
ColorModelmakeLinear_sRGBCM(boolean premult)
Method that returns either Linear_sRGB_Pre or Linear_sRGB_UnPre based on premult flag.
return premult ? Linear_sRGB_Pre : Linear_sRGB_Unpre;
BufferedImagemakeRgbImage(int[][] rbgImage)
make Rgb Image
BufferedImage image = new BufferedImage(rbgImage.length, rbgImage[0].length, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < rbgImage.length; ++x) {
    for (int y = 0; y < rbgImage[x].length; ++y) {
        image.setRGB(x, y, (int) rbgImage[x][y]);
return image;
int[]msAccesToRGBa(int code)
converts colour format

Color c = new Color(code);
return colorToRGBa(c);