Android examples for Graphics:Color Alpha
Modulate the color to new alpha
//package com.java2s; public class Main { /**//from w ww. j a v a 2 s. co m * Modulate the color to new alpha * * @param color Color * @param alpha Modulate alpha * @return Modulate alpha color */ public static int modulateColorAlpha(int color, int alpha) { int colorAlpha = color >>> 24; int scale = alpha + (alpha >> 7); int newAlpha = colorAlpha * scale >> 8; int r = (color >> 16) & 0xFF; int g = (color >> 8) & 0xFF; int b = color & 0xFF; return newAlpha << 24 | r << 16 | g << 8 | b; } }