Android实现水印效果
16lz
2021-01-23
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采用那只笔绘制
更多相关文章
- 【android】模拟点击某个指定坐标作用在View上
- 检测Android中触摸屏手势的动作与坐标
- 布局文件绘制圆角矩形 背景图片
- android实现圆角矩形背景的方法
- 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法(android)
- android中的坐标变换
- Android在源图片上的XY坐标再画一个图片
- Android23-视图坐标系以及MotionEvent事件