Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;

public class Main {

    public static Bitmap getTableBitmapFromData(int rows, int cols, int size) {
        int[] pixels = createTableData(rows, cols, size);
        return getBitmapFromData(pixels, cols * size, rows * size);
    }

    protected static int[] createTableData(int rows, int cols, int size) {
        int width = cols * size;
        int height = rows * size;
        int[] pixels = new int[width * height];
        int k = 0;
        for (int j = 0; j < height; j++) {
            for (int i = 0; i < width; i++) {
                if (i == width - 1 || j == height - 1 || (i % size) == 0 || (j % size) == 0) {
                    pixels[k++] = 0xff000000;
                } else {
                    pixels[k++] = 0xffffffff;
                }
            }
        }
        return pixels;
    }

    protected static Bitmap getBitmapFromData(int[] pixels, int width, int height) {
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
        return bitmap;
    }
}