Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Color;

public class Main {

    public static int toAlpha(int color, int alpha) {
        int r = getRed(color);
        int g = getGreen(color);
        int b = getBlue(color);
        return Color.argb(alpha, r, g, b);
    }

    public static int getRed(int color) {
        int red = (color & 0xff0000) >> 16;
        return red;
    }

    public static int getGreen(int color) {
        int green = (color & 0x00ff00) >> 8;
        return green;
    }

    public static int getBlue(int color) {
        int blue = (color & 0x0000ff);
        return blue;
    }
}