Java examples for 2D Graphics:Color Alpha
Returns the alpha channel of the color
/**/*from w w w. ja v a2s . c om*/ * Utility class to deal with ARGB color format * * @author Aritz Lopez * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) */ //package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int color = 2; System.out.println(getAlpha(color)); } /** * The mask to get the two least significant bytes of an integer; */ public static final int MASK = 0xFF; /** * The shifting used to put the alpha component in position */ public static final int ALPHA_SHIFT = 24; /** * Returns the alpha channel of the color * * @param color The color to get the alpha channel of * @return The alpha channel of the color */ public static int getAlpha(final int color) { return (color >> ALPHA_SHIFT) & MASK; } }