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;

import android.graphics.Canvas;

import android.support.annotation.NonNull;

public class Main {
    /**
     * Create a bitmap from a background and a foreground bitmap
     *
     * @param background The bitmap placed in the background
     * @param foreground The bitmap placed in the foreground
     * @return the merged bitmap
     */
    public static Bitmap mergeBitmap(@NonNull Bitmap background, @NonNull Bitmap foreground) {
        Bitmap result = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig());
        Canvas canvas = new Canvas(result);
        canvas.drawBitmap(background, 0f, 0f, null);
        canvas.drawBitmap(foreground, 10, 10, null);
        return result;
    }
}