Hexadecimal for Color Name

0

I have my final project to present this Monday, and it's an android app made with Android Studio.

My app captures colors with the camera and returns a value

I have already created an XML file with more than 1000 colors with their names and their HEX value, which I added manually.

<resources>
<color name="AliceBlue">#f0f8ff</color>
<color name="AntiqueWhite">#faebd7</color>
<color name="AntiqueWhite1">#ffefdb</color>
<color name="AntiqueWhite2">#eedfcc</color>
<color name="AntiqueWhite3">#cdc0b0</color>
<color name="AntiqueWhite4">#8b8378</color>
<color name="aquamarine1">#7fffd4</color>
<color name="aquamarine2">#76eec6</color>
<color name="aquamarine4">#458b74</color>
<color name="azure1">#f0ffff</color>
<color name="azure2">#e0eeee</color>
<color name="azure3">#c1cdcd</color>
<color name="azure4">#838b8b</color>
<color name="beige">#f5f5dc</color>
<color name="bisque1">#ffe4c4</color>
<color name="bisque2">#eed5b7</color>
<color name="bisque3">#cdb79e</color>
<color name="bisque4">#8b7d6b</color>
<color name="black">#000000</color>
<color name="BlanchedAlmond">#ffebcd</color>
<color name="blue1">#0000ff</color>
<color name="blue2">#0000ee</color>
<color name="blue4">#00008b</color>
<color name="BlueViolet">#8a2be2</color>
<color name="brown">#a52a2a</color>
<color name="brown1">#ff4040</color>
<color name="brown2">#ee3b3b</color>
<color name="brown3">#cd3333</color>
<color name="brown4">#8b2323</color>
<color name="burlywood">#deb887</color>
<color name="burlywood1">#ffd39b</color>
<color name="burlywood2">#eec591</color>
<color name="burlywood3">#cdaa7d</color>
<color name="burlywood4">#8b7355</color>
<color name="CadetBlue">#5f9ea0</color>
<color name="CadetBlue1">#98f5ff</color>
<color name="CadetBlue2">#8ee5ee</color>
<color name="CadetBlue3">#7ac5cd</color>
<color name="CadetBlue4">#53868b</color>
<color name="chartreuse1">#7fff00</color>

etc.

And now I need you guys to help with how I can get the camera to display the name instead of the HEX value, with the names I put in my XML file.

    public String getName() {
    return mName;
}

public void setName(String name) {
    mName = name;
}

public static String makeHexString(int value) {
    return "#" + Integer.toHexString(value).substring(2);
}

public static String makeRgbString(int value) {
    return "rgb(" + Color.red(value) + ", " + Color.green(value) + ", " + Color.blue(value) + ")";
}

public static String makeHsvString(int value) {
    float[] hsv = new float[3];
    Color.colorToHSV(value, hsv);
    return "hsv(" + (int) hsv[0] + "°, " + (int) (hsv[1] * 100) + "%, " + (int) (hsv[2] * 100) + "%)";
}

Where it says

public static String makeHexString(int value) {
return "#" + Integer.toHexString(value).substring(2);

}

It is where the HEX value of the colors is created, will it be possible to do in a way that my program verifies that this code is already in XML and that it can have a name ?, and if it does not say something of the genre "color name not identified "?

If you please, I need a lot of help !!

    
asked by anonymous 14.07.2018 / 20:35

0 answers