java 生成图片

2种方式

  //BufferedImage pictureDest = imageService.makePicture(inv, name, bgPicture);

ImageIO.write(image, "jpg", inv.getResponse().getOutputStream());

BufferedImage image = new BufferedImage(334, 448, BufferedImage.TYPE_3BYTE_BGR);
Graphics gra = image.getGraphics();
BufferedImage bg = ImageIO.read(new URL(bgPicture));
gra.drawImage(bg, 0, 0, null);
gra.setFont(new Font("宋体", Font.PLAIN, 32));
gra.drawString(name, 30, 50);

2


        String pictureDir = realPath + "people/nToWeibo/1.jpg";
        String webFilePath = "people/real.jpg";
        String outputFile = realPath + webFilePath;
        ImageInfo info = new ImageInfo(pictureDir);
        MagickImage image = new MagickImage(info);
        DrawInfo drawinfo = new DrawInfo(new ImageInfo());
        drawinfo.setFont(realPath + "people/wqy-zenhei.ttc");
        drawinfo.setText("中国人民共和国");
        drawinfo.setGeometry("+30+100");
        drawinfo.setBorderColor(PixelPacket.queryColorDatabase("black"));
        image.annotateImage(drawinfo);
        image.setFileName(outputFile);
        image.writeImage(new ImageInfo());
        image.destroyImages();
        return "@:" + webFilePath;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值