ColorUtil { public static int multiplyColorAlpha(int color, int alpha) { if (alpha == 255) { return color; } if (alpha == 0) { return color & 0x00FFFFFF; } alpha = alpha + (alpha >> 7); int colorAlpha = color >>> 24; int multipliedAlpha = colorAlpha * alpha >> 8; return (multipliedAlpha << 24) | (color & 0x00FFFFFF); }  static int multiplyColorAlpha(int color, int alpha); static int getOpacityFromColor(int color);  }
@Test public void testMultiplyColorAlpha() { assertEquals(0x00123456, ColorUtil.multiplyColorAlpha(0xC0123456, 0)); assertEquals(0x07123456, ColorUtil.multiplyColorAlpha(0xC0123456, 10)); assertEquals(0x96123456, ColorUtil.multiplyColorAlpha(0xC0123456, 200)); assertEquals(0xC0123456, ColorUtil.multiplyColorAlpha(0xC0123456, 255)); }