e585. Converting Between RGB and HSB Colors

Posted borter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了e585. Converting Between RGB and HSB Colors相关的知识,希望对你有一定的参考价值。

This example demonstrates how to convert between a color value in RGB (three integer values in the range 0 to 255 representing red, green, and blue) and HSB (three floating point values in the range 0 to 1.0 representing hue, saturation, and brightness).

    // Specify 3 RGB values
    int red = 0x33;
    int green = 0x66;
    int blue = 0x99;
    
    // Convert RGB to HSB
    float[] hsb = Color.RGBtoHSB(red, green, blue, null);
    float hue = hsb[0];          // .58333
    float saturation = hsb[1];   // .66667
    float brightness = hsb[2];   // .6
    
    // Convert HSB to RGB value
    int rgb = Color.HSBtoRGB(hue, saturation, brightness);
    red = (rgb>>16)&0xFF;
    green = (rgb>>8)&0xFF;
    blue = rgb&0xFF;

 

Related Examples

以上是关于e585. Converting Between RGB and HSB Colors的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces 585E. Present for Vitalik the Philatelist(容斥)

Switch between Server Core mode and Server GUI mode in Windows Server 2012 R2

CodeForces585 E. Present for Vitalik the Philatelist

Codeforces Round #585 (Div. 2) B.The Number of Products(动态规划)

e609. Listening to All Focus Changes Between Components in an Application

使用 Julia 库时遇到问题