BitmapUtil { public static Picture fromBitmap(Bitmap src) { return inst().fromBitmapImpl(src); }  static Picture fromBitmap(Bitmap src); static void fromBitmap(Bitmap src, Picture dst); static Bitmap toBitmap(Picture pic); static void toBitmap(Picture src, Bitmap dst); Picture fromBitmapImpl(Bitmap src); void fromBitmapImpl(Bitmap src, Picture dst); Bitmap toBitmapImpl(Picture pic); void toBitmapImpl(Picture src, Bitmap dst);  }
@Test public void testFromBitmap() { Bitmap src = mock(Bitmap.class); when(src.getWidth()).thenReturn(16); when(src.getHeight()).thenReturn(16); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { int[] pix = invocation.getArgumentAt(0, CLASS_INT_ARRAY); for (int i = 0; i < 256; i++) pix[i] = (255 << 24) | (i << 16) | (i << 8) | i; return null; } }).when(src).getPixels(any(CLASS_INT_ARRAY), eq(0), eq(16), eq(0), eq(0), eq(16), eq(16)); Picture dst = Picture.create(16, 16, ColorSpace.RGB); BitmapUtil.fromBitmap(src, dst); for (int i = 0; i < 256; i++) { Assert.assertEquals(dst.getPlaneData(0)[i * 3], i - 128); Assert.assertEquals(dst.getPlaneData(0)[i * 3 + 1], i - 128); Assert.assertEquals(dst.getPlaneData(0)[i * 3 + 2], i - 128); } }