Android 图片水印

/* 时间水印处理 */
Time t = new Time();
t.setToNow(); // 取得系统时间。
int year = t.year;
int month = t.month;
int date = t.monthDay;
int hour = t.hour;
int minute = t.minute;
int second = t.second;
int w = bmp.getWidth(), h = bmp.getHeight();
String mstrTitle = year + "-" + month + "-" + date
		+ "," + hour + ":" + minute + ":" + second
		+ "---" + Myaddress;
Bitmap mbmpTest = Bitmap.createBitmap(w, h,
		Config.ARGB_8888);
Canvas canvasTemp = new Canvas(mbmpTest);
Paint p = new Paint();
String familyName = "宋体";
Typeface font = Typeface.create(familyName,
		Typeface.BOLD);
p.setColor(Color.RED);
p.setTypeface(font);
p.setTextSize(22);
canvasTemp.drawBitmap(bmp, 0, 0, p);
canvasTemp.drawText(mstrTitle, 0, 20, p);
mbmpTest.compress(CompressFormat.JPEG, 100, bos);

1. 创建一个新的Bitmap, 2.在新的Bitmap中写入原始图片, 3.写入你需要的文字水印

你可能感兴趣的:(android)