加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

如何将BufferedImage转换/转换为图像?

发布时间:2020-12-15 04:53:28 所属栏目:Java 来源:网络整理
导读:我想将Buffered Image转换为java.awt.Image. 我的源图像是tif所以我使用JAI将其读作PlanarImage: PlanarImage source = JAI.create(“fileload”,IMG_DIR + tagImgName); 然后我将它作为对象属性保存为BufferedImage tagImg = source.getAsBufferedImage();
我想将Buffered Image转换为java.awt.Image.

我的源图像是tif所以我使用JAI将其读作PlanarImage:

PlanarImage source = JAI.create(“fileload”,IMG_DIR + tagImgName);

然后我将它作为对象属性保存为BufferedImage

tagImg = source.getAsBufferedImage();

对于.pdf-Export(通过iText)我需要它作为java.awt.Image

谢谢!

解决方法

java.awt.image.BufferedImage已经是 java.awt.Image的子类,因此您不需要任何转换或转换.您可以使用BufferedImage代替Image.

你可以直接这样做:

Image tagImg = source.getAsBufferedImage();
// use tagImg with iText library here

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读