7***@qq.com
7***@qq.com
  • 发布:2023-11-03 10:40
  • 更新:2023-11-03 11:32
  • 阅读:112

#插件讨论# 【 水印相机-XL - uniapp_hikha 】求安卓版本

分类:uni-app
关联插件: 水印相机-XL

安卓版本会出?

2023-11-03 10:40 负责人:无 分享
已邀请:
套马杆的套子

套马杆的套子 - 没有解决不了的问题,只有解决不完的问题

后台也可以自己增加水印
/**

  • 给图片添加单个文字水印、可设置水印文字旋转角度
  • @param source 需要添加水印的图片路径(如:F:/images/6.jpg)
  • @param output 添加水印后图片输出路径(如:F:/images/)
  • @param imageName 图片名称(如:11111)
  • @param imageType 图片类型(如:jpg)
  • @param color 水印文字的颜色
  • @param word 水印文字
  • @param degree 水印文字旋转角度,为null表示不旋转
  • @param x x偏离
  • @param y y偏离
    /
    public static String markImageBySingleText(String source,String output,String imageName,String imageType,Color color,String word,Integer degree,int x,int y) {
    String result = "添加文字水印出错";
    try {
    //读取原图片信息
    File file = new File(source);
    if (!file.isFile()) {
    return file + " 不是一个图片文件!";
    }
    Image img = ImageIO.read(file);
    int width = img.getWidth(null);
    int height = img.getHeight(null);
    //加水印
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = bi.createGraphics();
    g.drawImage(img, 0, 0, width, height, null);
    //设置水印字体样式
    Font font = new Font("宋体", Font.PLAIN, 50);
    //根据图片的背景设置水印颜色
    g.setColor(color);
    if (null != degree) {
    //设置水印旋转
    g.rotate(Math.toRadians(degree),(double) bi.getWidth() / 2, (double) bi.getHeight() / 2);
    }
    g.setFont(font);
    /
    int x = width/3;
    int y = height/2;*/
    //水印位置
    g.drawString(word, x, y);
    g.dispose();
    //输出图片
    File sf = new File(output, imageName+"."+imageType);
    ImageIO.write(bi, imageType, sf); // 保存图片
    result = "图片完成添加Word水印";
    } catch (Exception e) {
    e.printStackTrace();
    }
    return result;
    }

要回复问题请先登录注册