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;
    }

  • 相关阅读:
    Oracle数据库五种约束
    Oracle中sql的基本使用
    暮光之城》剧本
    英语电影剧本大全(中英对照)
    加勒比海盗1英文剧本
    公主日记英文剧本
    教父2-英文版
    <老友记>学习笔记
    霍夫变换Hough
    景深(Depth of Field)
  • 原文地址:https://www.cnblogs.com/loveLearning/p/2682215.html
Copyright © 2011-2022 走看看