android 添加水印效果的实现
来源:互联网 发布:快手刷播放软件 编辑:程序博客网 时间:2024/05/20 13:19
Bitmap photo = BitmapFactory.decodeResource(r, res);Bitmap icon = Bitmap.createBitmap(width, hight, Bitmap.Config.ARGB_8888); //建立一个空的BItMapCanvas canvas = new Canvas(icon);//初始化画布 绘制的图像到icon上Paint photoPaint = new Paint(); //建立画笔photoPaint.setDither(true); //获取跟清晰的图像采样photoPaint.setFilterBitmap(true);//过滤一些Rect src = new Rect(0, 0, photo.getWidth(), photo.getHeight());//创建一个指定的新矩形的坐标Rect dst = new Rect(0, 0, width, hight);//创建一个指定的新矩形的坐标canvas.drawBitmap(photo, src, dst, photoPaint);//将photo 缩放或则扩大到 dst使用的填充区photoPaintPaint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);//设置画笔textPaint.setTextSize(20.0f);//字体大小textPaint.setTypeface(Typeface.DEFAULT_BOLD);//采用默认的宽度textPaint.setColor(Color.RED);//采用的颜色textPaint.setShadowLayer(3f, 1, 1,r.getColor(android.R.color.background_dark));//影音的设置canvas.drawText(str, 20, 26, textPaint);//绘制上去 字,开始未知x,y采用那只笔绘制