combine Images - Android android.graphics

Android examples for android.graphics:Image Load Save

Description

combine Images

Demo Code

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

public class Main{

    public static Bitmap combineImages(Bitmap c, Bitmap s) {
        Bitmap cs = null;//from w  w w  . j a  v a2s  .  c om

        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_8888);

        Canvas comboImage = new Canvas(cs);

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

        return cs;
    }

}

Related Tutorials