抗锯齿也加上了就是生成的不太清晰。
public static void main(String[] args) throws IOException {
File destFile = new File("D:/image/jobDetail_share.png");
BufferedImage img = new BufferedImage(300, 300, BufferedImage.TYPE_INT_RGB);
Graphics2D g = img.createGraphics();
// 填充白色背景
g.setColor(Color.white);
g.fillRect(0, 0, img.getWidth(), img.getHeight());
// 抗锯齿 添加文字
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
g.setFont(new Font("微软雅黑", Font.PLAIN, 14));
g.setPaint(new Color(103, 101, 120));
g.drawString("长按识别小程序码", 20, 40);
g.drawString("查看职位详情、在线投递简历", 20, 60);
g.dispose();
// 输出
ImageIO.write(img, "png", destFile);
}
不知道怎么展示图片,先使用有道吧,捂脸: http://note.youdao.com/noteshare?id=35e44b6160aed0da4a7738e90c4578eb