BitmapUtils { public static int[] rotate(int[] pixels, int width, int height, @Nullable int[] newPixels) { newPixels = newPixels == null ? new int[width * height] : newPixels; for (int i = 0, n = width * height; i < n; i++) { int x = i % width; int y = i / width; int newX = height - 1 - y; int newY = x; newPixels[newY * height + newX] = pixels[i]; } return newPixels; }  static void initialize(Context context); static long availableMemory(); static Bitmap decodeStream(@NonNull InputStreamPipe isp, int maxWidth, int maxHeight,
            int pixels, boolean checkMemory, boolean justCalc, int[] sampleSize); static Bitmap decodeStream(@NonNull InputStreamPipe isp, int maxWidth, int maxHeight); static int[] rotate(int[] pixels, int width, int height, @Nullable int[] newPixels); static Context sContext; }
@Test public void testRotate() { int[] pixels = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; int[] expected = new int[] { 9, 5, 1, 10, 6, 2, 11, 7, 3, 12, 8, 4 }; assertArrayEquals(BitmapUtils.rotate(pixels, 4, 3, null), expected); }
@Test public void testRotateFit() { int[] pixels1 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; int[] pixels2 = BitmapUtils.rotate(pixels1, 4, 3, null); int[] pixels3 = BitmapUtils.rotate(pixels2, 3, 4, null); int[] pixels4 = BitmapUtils.rotate(pixels3, 4, 3, null); int[] pixels5 = BitmapUtils.rotate(pixels4, 3, 4, null); assertArrayEquals(pixels1, pixels5); }