Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;

import android.graphics.Canvas;

public class Main {
    private static Bitmap buildBitmap(ArrayList<Bitmap> bitmaps) {
        if (bitmaps == null || bitmaps.size() == 0) {
            return null;
        }
        int width = 0;
        int height = 0;
        for (int i = 0; i < bitmaps.size(); i++) {
            width = width + bitmaps.get(i).getWidth();
            height = Math.max(height, bitmaps.get(i).getHeight());
        }
        Bitmap resultBitmap = Bitmap.createBitmap(width, height, Config.ARGB_4444);
        int drawWidth = 0;
        Canvas canvas = new Canvas(resultBitmap);
        for (int j = 0; j < bitmaps.size(); j++) {
            drawWidth = j * bitmaps.get(j).getWidth();
            canvas.drawBitmap(bitmaps.get(j), drawWidth, 0, null);
        }
        return resultBitmap;
    }
}