Java RGB Color Create toRGB(String hexString)

Here you can find the source of toRGB(String hexString)

Description

to RGB

License

Apache License

Declaration

public static int[] toRGB(String hexString) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int[] toRGB(int value) {
        int[] rgb = new int[3];
        rgb[0] = value >> 16 & 0xff;
        rgb[1] = value >> 8 & 0xff;
        rgb[2] = value & 0xff;/*w w w .  j a v  a  2 s  .  c  o  m*/
        return rgb;
    }

    public static int[] toRGB(String hexString) {
        if (hexString.startsWith("0x")) {
            hexString = hexString.substring(2);
        } else if (hexString.startsWith("#")) {
            hexString = hexString.substring(1);
        }

        int value = Integer.parseInt(hexString, 16);
        return toRGB(value);
    }
}

Related

  1. toRGB(final int r, final int g, final int b, final int a)
  2. toRGB(float h, float s, float l)
  3. toRGB(int alpha, int red, int green, int blue)
  4. toRGB(int color)
  5. toRgb(int r, int g, int b)
  6. toRGB15(int x)
  7. toRGBA(float[] colors)
  8. toRGBA(int argb)
  9. toRGBA(int color)