Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.graphics.Bitmap;

public class Main {

    public static Bitmap[] splitBitmap(Bitmap pic, int row, int col) {
        int tileWidth = pic.getWidth() / col;
        int tileHeight = pic.getHeight() / row;

        Bitmap[] tiles = new Bitmap[row * col];
        for (int r = 0; r < row; r++) {
            for (int c = 0; c < col; c++) {
                tiles[r * col + c] = Bitmap.createBitmap(pic, c * tileWidth, r * tileHeight, tileWidth, tileHeight);
            }
        }
        return tiles;
    }
}