Android 添加水印, 以及屏幕存取

/**
* 获取水印
*/

try {

String s = CustomPreferences.getUserInfo().getAccountNo().substring(7,11);

View view = getWindow().getDecorView();

Bitmap bitmap = Bitmap.createBitmap(350, 350, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawColor(Color.WHITE);
Paint paint = new Paint();
paint.setColor(Color.GRAY);
paint.setAlpha(80);
paint.setAntiAlias(true);
paint.setTextAlign(Paint.Align.LEFT);
paint.setTextSize(50);
Path path = new Path();
path.moveTo(30, 150);
path.lineTo(300, 0);
canvas.drawTextOnPath(CustomPreferences.getUserInfo().getUserName()+s, path, 0, 30, paint);

BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
bitmapDrawable.setDither(true);
view.setBackground(bitmapDrawable);

}catch (Exception e){

}

* 获取水印
*/

 

 

// 截取屏幕保存


private Bitmap geBitMap(View mView){
mView.setDrawingCacheEnabled(true);
mView.measure(
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
mView.layout(0, 0, mView.getMeasuredWidth(),
mView.getMeasuredHeight());
mView.buildDrawingCache();
Bitmap bitmap = cc.getDrawingCache();


return bitmap;
}

关于bitmap 的储存自己网上搜索吧! 记录备份

转载于:https://www.cnblogs.com/dkqdream/p/7683089.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值