Converting from HSV (HSB in Java) to RGB without using java.awt.Color (disallowed on Google App Engine)

前端 未结 7 1133
独厮守ぢ
独厮守ぢ 2020-12-09 12:44

I figured I should post this question, even if I have already found a solution, as a Java implementation was not readily available when I searched for it.

Using HSV

相关标签:
7条回答
  • 2020-12-09 13:19

    Use ColorUtils which provides

    HSLToColor(float\[\] hsl) 
    

    And

    [RGBToHSL(int r, int g, int b, float\[\] hsl)]
    

    Methods which are very easy to convert to each other!

    For example:

    float[] hsl = new float[]{1.5, 2.0, 1.5};
    int color = ColorUtils.HSLToColor(hsl);
    

    Now get the color

    float[] hslStub = new float[3];
    float[] hslFromColor = ColorUtils.colorToHSL(color, hslStub);
    

    Now get the hsl

    Here is the sourcecode.

    0 讨论(0)
提交回复
热议问题