Combine two Images - Android Graphics

Android examples for Graphics:Bitmap Combine

Description

Combine two Images

Demo Code


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

public class Main {
    public static Bitmap CombineImages(Bitmap c, Bitmap s) {
        Bitmap cs = null;/*from  w  w  w.ja  v  a2  s .c  o m*/

        int width, height = 0;

        if (c.getWidth() > s.getWidth()) {
            width = c.getWidth() + s.getWidth();
            height = c.getHeight();
        } else {
            width = s.getWidth() + s.getWidth();
            height = c.getHeight();
        }

        cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);

        Canvas comboImage = new Canvas(cs);

        comboImage.drawBitmap(c, 0f, 0f, null);
        comboImage.drawBitmap(s, c.getWidth(), 0f, null);

        return cs;
    }
}

Related Tutorials