Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何调整色码的色调?_Java_Android - Fatal编程技术网

Java 如何调整色码的色调?

Java 如何调整色码的色调?,java,android,Java,Android,也许有人知道Java(Android)中一种将色调应用于颜色代码的方法 例如,如果我有#1589FF并应用180色调,我应该得到#FF8B14。这应该可以做到: Color c = new Color(0x15, 0x89, 0xFF); // Get saturation and brightness. float[] hsbVals = new float[3]; Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbVals);

也许有人知道Java(Android)中一种将色调应用于颜色代码的方法


例如,如果我有#1589FF并应用180色调,我应该得到#FF8B14。

这应该可以做到:

Color c = new Color(0x15, 0x89, 0xFF);

// Get saturation and brightness.
float[] hsbVals = new float[3];
Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbVals);

// Pass .5 (= 180 degrees) as HUE
c = new Color(Color.HSBtoRGB(0.5f, hsbVals[1], hsbVals[2]));

这是另一个很好的方法

    /**
     * @param color the ARGB color to convert. The alpha component is ignored
     * @param hueFactor The factor of hue, an int [0 .. 360)
     * @return new color with the specified hue.
     */
    public int hue(int color, int hueFactor) {
        float[] hsl= new float[3];
        ColorUtils.colorToHSL(color,hsl);
        hsl[0]=hueFactor;
        return ColorUtils.HSLToColor(hsl);
    }

@也许这是个很无聊的问题,但0.5是180吗?公式是什么?@VijayC,.5*360度=180度。@theficster510,
新颜色(yourInt)