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 的储存自己网上搜索吧! 记录备份
posted @ 2017-10-17 17:57  待飞的程序猿  阅读(2316)  评论(0编辑  收藏  举报