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 horizontally into a List * composed by {@code piecesNum} of Bitmaps. * * @param source The source Bitmap. * @param piecesNum int that represents the number of pieces. * @return The List of Bitmap's pieces. */ public static List<Bitmap> splitImageHorizontally(Bitmap source, int piecesNum) { List<Bitmap> pieces = new ArrayList<>(); int width = source.getWidth() / piecesNum; int start = 0; for (int i = 0; i < piecesNum; i++) { Bitmap pieceBitmap = Bitmap.createBitmap(source, start, 0, width - 1, source.getHeight() - 1); pieces.add(pieceBitmap); start = (source.getWidth() / piecesNum) * (i + 1); } return pieces; } }