color Intensity - Android Graphics

Android examples for Graphics:Color Operation

Description

color Intensity

Demo Code


//package com.java2s;
import android.graphics.Color;

public class Main {
    public static float[] colorIntensity(int color) {
        float[] ret = new float[4];
        ret[0] = redIntensity(color);//from  w  w  w. j  a  v a  2s  .  c o  m
        ret[1] = greenIntensity(color);
        ret[2] = blueIntensity(color);
        ret[3] = alphaIntensity(color);
        return ret;
    }

    public static float redIntensity(int color) {
        return ((float) (Color.red(color))) / 255;
    }

    public static float greenIntensity(int color) {
        return ((float) Color.green(color)) / 255;
    }

    public static float blueIntensity(int color) {
        return ((float) Color.blue(color)) / 255;
    }

    public static float alphaIntensity(int color) {
        return ((float) Color.alpha(color)) / 255;
    }
}

Related Tutorials