Android examples for Graphics:Color
convert ABGR Packed Int To Color
public class Main{ public static Color convertABGRPackedIntToColor(final int pABGRPackedInt) { final Color color = new Color(); convertABGRPackedIntToColor(pABGRPackedInt, color); return color; }/* ww w .ja v a 2 s . c o m*/ public static void convertABGRPackedIntToColor( final int pABGRPackedInt, final Color pColor) { final float alpha = ColorUtils .extractAlphaFromABGRPackedInt(pABGRPackedInt); final float blue = ColorUtils .extractBlueFromABGRPackedInt(pABGRPackedInt); final float green = ColorUtils .extractGreenFromABGRPackedInt(pABGRPackedInt); final float red = ColorUtils .extractRedFromABGRPackedInt(pABGRPackedInt); pColor.set(red, green, blue, alpha); } public static float extractAlphaFromABGRPackedInt( final int pABGRPackedInt) { return ((pABGRPackedInt >> Color.ABGR_PACKED_ALPHA_SHIFT) & 0xFF) / 255.0f; } public static float extractBlueFromABGRPackedInt( final int pABGRPackedInt) { return ((pABGRPackedInt >> Color.ABGR_PACKED_BLUE_SHIFT) & 0xFF) / 255.0f; } public static float extractGreenFromABGRPackedInt( final int pABGRPackedInt) { return ((pABGRPackedInt >> Color.ABGR_PACKED_GREEN_SHIFT) & 0xFF) / 255.0f; } public static float extractRedFromABGRPackedInt(final int pABGRPackedInt) { return ((pABGRPackedInt >> Color.ABGR_PACKED_RED_SHIFT) & 0xFF) / 255.0f; } }