zoukankan      html  css  js  c++  java
  • Java给图片加水印

    /**
    * 方法描述:<b>给图片增加水印.</b></br>
    * 备 注: 在图片上写字符串
    * 创 建 人: bo.gaobo</br>
    * 创建日期: 2012-09-07</br>
    * @param originalUrl 原始图片存储路径
    * @param oldImg 原图片
    * @param str 增加的字符串
    * @param xLocation x坐标
    * @param yLocation y坐标
    * @param fontColor 颜色
    * @param fontSize 字号
    * @param typeFace 字体
    * @param fileType 文件类型
    */
    public static BufferedImage addStringToImg(String originalUrl, BufferedImage oldImg,String str,int xLocation,int yLocation, Color fontColor, int fontSize, String typeFace, String fileType) throws IOException{
    FileOutputStream output = new FileOutputStream(originalUrl);
    BufferedImage buffImg = oldImg;
    Graphics2D g = buffImg.createGraphics();
    g = buffImg.createGraphics();
    g.drawImage(buffImg, null, 0, 0);
    g.setColor(fontColor); //设置字体颜色
    g.setFont(new Font(typeFace, Font.PLAIN, fontSize)); //设置字体和字号
    g.drawString(str, xLocation, yLocation); //把字符串放在对应的坐标处
    g.dispose();
    ImageIO.write(buffImg, fileType, output); //设置文件类型
    output.close();
    return buffImg;
    }

  • 相关阅读:
    ASP.NET线程相关配置
    ECshop 数据库表结构
    PHPnow 升级后 PHP不支持GD、MySQL
    C# 创建iis站点以及IIS站点属性,iis不能启动站点
    CSPS_107
    CSPS_106
    CSPS_105
    CSPS_104
    CSPS_103
    CSPS_102
  • 原文地址:https://www.cnblogs.com/loveLearning/p/2682215.html
Copyright © 2011-2022 走看看