Android.graphics.Color

Source: Internet
Author: User

This class defines static constants and functions that are created and converted to a color of type int. The color is represented by the number of int, consisting of 4 bytes, which is a R G B, the value of the int is determined, the value of the transparency can only exist on the byte of A and cannot exist in the color. stored in the way (Alpha << 24) | (Red << 16) | (Green << 8) | Blue. Each part of the value range is 0-255,0 indicates no, 255 means filled. The value of opaque black is 0xff000000, and the value of opaque white is 0xffffffff.

public static int hsvtocolor(float[] HSV)

Convert HSV content to color, where alpha is set to 0XFF,HSV with three members, Hsv[0] range is [0,360], indicates color, hsv[1] range [0,1] indicates saturation, hsv[2] range [0,1] represents values, and if their values are out of range, Then they are truncated to a range of values.

public static int hsvtocolor(int alpha, float[] HSV)

Ditto, but the alpha value is no longer 0xff, but is set by the parameter

Public static void RGBTOHSV(int red, int green, int blue, float[] HSV)

Convert RGB values to HSV values

public static int alpha(int color)

Gets the alpha value of color, which is equivalent to color>>24;

public static int blue(int color)

Gets the blue value of color, equivalent to color&0xff;

public static int ARGB(int alpha, int red, int green, int blue)

Get an int color from the value of ARGB, note that the range of each parameter is 0-255, because there is no scope check, and if it is out of range, the returned color value is unpredictable.

Public static void COLORTOHSV(int color, float[] HSV)

Converts the value of the color to the HSV value, equivalent to RGBTOHSV (((color>>16) &0xff), ((color>>8) &0xff), (COLOR&0XFF), HSV);

public static int green(int color)

Gets the green value of color, equivalent to (color>>8) &0xff

public static int parsecolor(String colorstring)

The int type color is parsed from the string, and if it is not parsed, an exception is thrown that supports the format #rrggbb #AARRGGBB ' Red ', ' blue ', ' green ', ' black ', ' white ', ' gray ', ' cyan ', ' Magenta ', ' yellow ', ' lightgray ', ' Darkgray '

public static int red(int color)

Gets the red value of color, equivalent to (COLOR>>16) &0xff

public static int RGB(int red, int green, int blue)

Gets an int color from the RGB value, where alpha is set to 0xFF, and the function does not have a range check, and the returned color may be unpredictable if the argument goes out of range

Android.graphics.Color

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.