Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import java.util.ArrayList; import java.util.List; public class Main { /** * Method to split an image in {@code numStages} pieces. * * @param bmpOriginal The original Bitmap. * @param numStages int that represents the number of pieces. * @return A List of Bitmap, i.e. a List of pieces of {@code bmpOriginal} */ public static List<Bitmap> splitImage(Bitmap bmpOriginal, int numStages) { List<Bitmap> pieces = new ArrayList<>(); int width = bmpOriginal.getWidth() / numStages; int start = 0; for (int i = 0; i < numStages; i++) { Bitmap pieceBitmap = Bitmap.createBitmap(bmpOriginal, start, 0, width - 1, bmpOriginal.getHeight() - 1); pieces.add(pieceBitmap); start = (bmpOriginal.getWidth() / numStages) * (i + 1); } return pieces; } }