//读取图片文件,得到BufferedImage对象
BufferedImage bimg=ImageIO.read(new FileInputStream("图片文件路径"));
//得到Graphics2D 对象
Graphics2D g2d=(Graphics2D)bimg.getGraphics();
//设置颜色和画笔粗细
g2d.setColor(Color.RED);
g2d.setStroke(new BasicStroke(3));
//绘制图案或文字
g2d.drawString("文本", x坐标, y坐标);
//保存新图片
ImageIO.write(bimg, "JPG",new FileOutputStream("文件路径"));