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

前端 未结 7 1187
独厮守ぢ
独厮守ぢ 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.

提交回复
热议问题