ColorUtil { public static int getOpacityFromColor(int color) { int colorAlpha = color >>> 24; if (colorAlpha == 255) { return PixelFormat.OPAQUE; } else if (colorAlpha == 0) { return PixelFormat.TRANSPARENT; } else { return PixelFormat.TRANSLUCENT; } }  static int multiplyColorAlpha(int color, int alpha); static int getOpacityFromColor(int color);  }
@Test public void testGetOpacityFromColor() { assertEquals(PixelFormat.TRANSPARENT, ColorUtil.getOpacityFromColor(0x00000000)); assertEquals(PixelFormat.TRANSPARENT, ColorUtil.getOpacityFromColor(0x00123456)); assertEquals(PixelFormat.TRANSPARENT, ColorUtil.getOpacityFromColor(0x00FFFFFF)); assertEquals(PixelFormat.TRANSLUCENT, ColorUtil.getOpacityFromColor(0xC0000000)); assertEquals(PixelFormat.TRANSLUCENT, ColorUtil.getOpacityFromColor(0xC0123456)); assertEquals(PixelFormat.TRANSLUCENT, ColorUtil.getOpacityFromColor(0xC0FFFFFF)); assertEquals(PixelFormat.OPAQUE, ColorUtil.getOpacityFromColor(0xFF000000)); assertEquals(PixelFormat.OPAQUE, ColorUtil.getOpacityFromColor(0xFF123456)); assertEquals(PixelFormat.OPAQUE, ColorUtil.getOpacityFromColor(0xFFFFFFFF)); }