Build 1.0_r1(from source)

android.graphics
Class Color

java.lang.Object
  extended by android.graphics.Color

public class Color
extends Object

The Color class defines methods for creating and converting color ints. Colors are represented as packed ints, made up of 4 bytes: alpha, red, green, blue. The values are unpremultiplied, meaning any transparency is stored solely in the alpha component, and not in the color components. The components are stored as follows (alpha < 24)="" |="" (red="">< 16)="" |="" (green="">< 8)="" |="" blue.="" each="" component="" ranges="" between="" 0..255="" with="" 0="" meaning="" no="" contribution="" for="" that="" component,="" and="" 255="" meaning="" 100%="" contribution.="" thus="" opaque-black="" would="" be="" 0xff000000="" (100%="" opaque="" but="" no="" contributes="" from="" red,="" gree,="" blue,="" and="" opaque-white="" would="" be="" 0xffffffff="">


Field Summary
static int BLACK
           
static int BLUE
           
static int CYAN
           
static int DKGRAY
           
static int GRAY
           
static int GREEN
           
static int LTGRAY
           
static int MAGENTA
           
static int RED
           
static int TRANSPARENT
           
static int WHITE
           
static int YELLOW
           
 
Constructor Summary
Color()
           
 
Method Summary
static int alpha(int color)
          Return the alpha component of a color int.
static int argb(int alpha, int red, int green, int blue)
          Return a color-int from alpha, red, green, blue components.
static int blue(int color)
          Return the blue component of a color int.
static void colorToHSV(int color, float[] hsv)
          Convert the argb color to its HSV components.
static int green(int color)
          Return the green component of a color int.
static int HSVToColor(float[] hsv)
          Convert HSV components to an ARGB color.
static int HSVToColor(int alpha, float[] hsv)
          Convert HSV components to an ARGB color.
static int parseColor(String colorString)
          Parse the color string, and return the corresponding color-int.
static int red(int color)
          Return the red component of a color int.
static int rgb(int red, int green, int blue)
          Return a color-int from red, green, blue components.
static void RGBToHSV(int red, int green, int blue, float[] hsv)
          Convert RGB components to HSV.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLACK

public static final int BLACK
See Also:
Constant Field Values

DKGRAY

public static final int DKGRAY
See Also:
Constant Field Values

GRAY

public static final int GRAY
See Also:
Constant Field Values

LTGRAY

public static final int LTGRAY
See Also:
Constant Field Values

WHITE

public static final int WHITE
See Also:
Constant Field Values

RED

public static final int RED
See Also:
Constant Field Values

GREEN

public static final int GREEN
See Also:
Constant Field Values

BLUE

public static final int BLUE
See Also:
Constant Field Values

YELLOW

public static final int YELLOW
See Also:
Constant Field Values

CYAN

public static final int CYAN
See Also:
Constant Field Values

MAGENTA

public static final int MAGENTA
See Also:
Constant Field Values

TRANSPARENT

public static final int TRANSPARENT
See Also:
Constant Field Values
Constructor Detail

Color

public Color()
Method Detail

alpha

public static int alpha(int color)
Return the alpha component of a color int. This is the same as saying color >>> 24


red

public static int red(int color)
Return the red component of a color int. This is the same as saying (color >> 16) & 0xFF


green

public static int green(int color)
Return the green component of a color int. This is the same as saying (color >> 8) & 0xFF


blue

public static int blue(int color)
Return the blue component of a color int. This is the same as saying color & 0xFF


rgb

public static int rgb(int red,
                      int green,
                      int blue)
Return a color-int from red, green, blue components. The alpha component is implicity 255 (fully opaque). These component values should be [0..255], but there is no range check performed, so if they are out of range, the returned color is undefined.

Parameters:
red - Red component [0..255] of the color
green - Green component [0..255] of the color
blue - Blue component [0..255] of the color

argb

public static int argb(int alpha,
                       int red,
                       int green,
                       int blue)
Return a color-int from alpha, red, green, blue components. These component values should be [0..255], but there is no range check performed, so if they are out of range, the returned color is undefined.

Parameters:
alpha - Alpha component [0..255] of the color
red - Red component [0..255] of the color
green - Green component [0..255] of the color
blue - Blue component [0..255] of the color

parseColor

public static int parseColor(String colorString)
Parse the color string, and return the corresponding color-int. If the string cannot be parsed, throws an IllegalArgumentException exception. Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'


RGBToHSV

public static void RGBToHSV(int red,
                            int green,
                            int blue,
                            float[] hsv)
Convert RGB components to HSV. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1]

Parameters:
red - red component value [0..255]
green - green component value [0..255]
blue - blue component value [0..255]
hsv - 3 element array which holds the resulting HSV components.

colorToHSV

public static void colorToHSV(int color,
                              float[] hsv)
Convert the argb color to its HSV components. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1]

Parameters:
color - the argb color to convert. The alpha component is ignored.
hsv - 3 element array which holds the resulting HSV components.

HSVToColor

public static int HSVToColor(float[] hsv)
Convert HSV components to an ARGB color. Alpha set to 0xFF. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.

Parameters:
hsv - 3 element array which holds the input HSV components.
Returns:
the resulting argb color

HSVToColor

public static int HSVToColor(int alpha,
                             float[] hsv)
Convert HSV components to an ARGB color. The alpha component is passed through unchanged. hsv[0] is Hue [0 .. 360) hsv[1] is Saturation [0...1] hsv[2] is Value [0...1] If hsv values are out of range, they are pinned.

Parameters:
alpha - the alpha component of the returned argb color.
hsv - 3 element array which holds the input HSV components.
Returns:
the resulting argb color

Build 1.0_r1(from source)

Please submit a feedback, bug or feature