Mix two Bitmap as one. - Android Graphics

Android examples for Graphics:Bitmap Combine

Description

Mix two Bitmap as one.

Demo Code


import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.PointF;

public class Main {
  /**/*from   www . j  a  va  2  s  . c om*/
   * Mix two Bitmap as one.
   * 
   * @param bitmapOne
   * @param bitmapTwo
   * @param point
   *          where the second bitmap is painted.
   * @return
   */
  public static Bitmap mixtureBitmap(Bitmap first, Bitmap second, PointF fromPoint) {
    if (first == null || second == null || fromPoint == null) {
      return null;
    }
    Bitmap newBitmap = Bitmap.createBitmap(first.getWidth(), first.getHeight(), Config.ARGB_8888);
    Canvas cv = new Canvas(newBitmap);
    cv.drawBitmap(first, 0, 0, null);
    cv.drawBitmap(second, fromPoint.x, fromPoint.y, null);
    cv.save();
    cv.restore();
    return newBitmap;
  }
}

Related Tutorials