zoukankan      html  css  js  c++  java
  • IO水印文字效果

    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.Random;
    import javax.imageio.ImageIO;
    public class Meinv {
     public static void main(String[] args) throws IOException {
      String src = "D:\Demo\op";
      String dst = "D:\Demo\op\ting3";
      BufferedImage s = ImageIO.read(new File (src));
    int width = s.getWidth();
    int height = s.getHeight();
    BufferedImage black = new BufferedImage(width, height,10);
    black.getGraphics().drawImage(s, 0, 0, width, height,null );
    BufferedImage i = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
    Graphics g = i .getGraphics();
    g.drawImage(black,0,0,width,height,null);
    Random rand = new Random();
    g.setColor(new Color(rand.nextInt(255),rand.nextInt(255),rand.nextInt(255)));
    g.fillRect(0, 0, width, height);

    g.setColor(new Color(255,255,255,120));
    g.setFont(new Font("",Font.BOLD,40));
    int x= width - 200;
    int y = height -40;
    g.drawString("王昭君",x,y);
     }
    }
  • 相关阅读:
    接口测试01
    mysql主从
    linux下配置JDK
    linux常用命令
    mysql基本语句
    线程与进程
    loadrunner函数
    设计模式-模板方法模式
    设计原则-CRP合成复用原则
    设计原则-LOD迪米特法则
  • 原文地址:https://www.cnblogs.com/wangqianbao/p/13088796.html
Copyright © 2011-2022 走看看