Android Canvas Draw add(Bitmap[] images)

Here you can find the source of add(Bitmap[] images)

Description

combines to Bitmap s

Parameter

Parameter Description
Images to be combine

Return

combined bitmap

Declaration

public static Bitmap add(Bitmap[] images) 

Method Source Code

//package com.java2s;

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

public class Main {
    /**//from  w  w  w  .  j a v a 2 s. c  o m
     * combines to {@link Bitmap}s
     * 
     * @param firstlayer
     * @param secondlayer
     * @return combined bitmap
     */
    public static Bitmap add(Bitmap firstlayer, Bitmap secondlayer) {
        Bitmap data = Bitmap.createBitmap(secondlayer.getWidth(),
                secondlayer.getHeight(), secondlayer.getConfig());
        Canvas temp = new Canvas(data);

        temp.drawBitmap(secondlayer, 0, 0, null);
        temp.drawBitmap(firstlayer, 0, 0, null);

        return data;
    }

    /**
     * combines to {@link Bitmap}s
     * 
     * @param Images
     *        to be combine
     * @return combined bitmap
     */
    public static Bitmap add(Bitmap[] images) {
        Bitmap data = Bitmap.createBitmap(images[0].getWidth(),
                images[0].getHeight(), images[0].getConfig());
        Canvas temp = new Canvas(data);

        for (int i = 0; i < images.length; i++) {
            temp.drawBitmap(images[i], 0, 0, null);
        }

        return data;
    }
}

Related

  1. drawText(String strMsg, Canvas g, Paint paint, int setx, int sety, int fg, int bg)
  2. drawTextAtCanvasCenter(Canvas canvas, Paint paint, String text)
  3. circle(Canvas canvas, int color, int stroke, float x, float y, float radius)
  4. rect(Canvas canvas, int color, int stroke, float x, float y, float width, float height)
  5. add(Bitmap firstlayer, Bitmap secondlayer)