图片添加水印功能

发布时间:2026/7/30 17:23:08
图片添加水印功能 此处是添加文字水印完整代码,添加图片水印把canvas.drawText方法换成canvas.drawBitmap方法。添加文字水印完整代码如下:public class WaterMarkUtil { static String filePath = ""; public static Bitmap drawMark(Context context, String imgPath, String markerText) { Bitmap bitmap; try { bitmap = Glide.with(context) .asBitmap() .load(imgPath) .submit() .get(); } catch (ExecutionException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } float scale = context.getResources().getDisplayMetrics().density; //创建一样大小的图片 Bitmap newBmp = Bitmap.createBitmap(bitmap.getWidth(), bitma