水印
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class SUIyin {
public static void main(String[] args) throws IOException {
BufferedImage i= ImageIO.read(new File("D:\\src\\timg[5].jpg"));
Graphics g = i.getGraphics();
g.setFont(new Font("微软雅黑",Font.BOLD,50));
g.drawString("王昭君", 40,160);
g.dispose();
ImageIO.write(i,"jpg",new File("D:\\src\\timg[5].jpg"));
BufferedImage i= ImageIO.read(new File("D:\\src\\timg[5].jpg"));
Graphics g = i.getGraphics();
g.setFont(new Font("微软雅黑",Font.BOLD,50));
g.drawString("王昭君", 40,160);
g.dispose();
ImageIO.write(i,"jpg",new File("D:\\src\\timg[5].jpg"));
}
}
運行結果