create Watermark Bitmap - Android Graphics

Android examples for Graphics:Texture

Description

create Watermark Bitmap

Demo Code

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

public class Main {

  public static Bitmap createWatermarkBitmap(Bitmap src, Bitmap watermark) {
    if (src == null) {
      return null;
    }/* w w w  . j ava 2  s  .  c  o m*/

    int w = src.getWidth();
    int h = src.getHeight();
    int ww = watermark.getWidth();
    int wh = watermark.getHeight();
    // create the new blank bitmap
    Bitmap newb = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas cv = new Canvas(newb);
    cv.drawBitmap(src, 0, 0, null);
    cv.drawBitmap(watermark, w - ww + 5, h - wh + 5, null);
    cv.save();
    cv.restore();
    return newb;
  }
}

Related Tutorials