如何投/转换一个BufferedImage成图像? [英] How to cast/convert a BufferedImage into an Image?

查看:228
本文介绍了如何投/转换一个BufferedImage成图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转换一个的BufferedImage java.awt.Image中

我的源图像TIF所以我用JAI读它为 PlanarImage

My source-image is tif so I use JAI to read it as PlanarImage:

PlanarImage源= JAI.create(fileload,IMG_DIR + tagImgName);

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

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

I then save it as an objects attribute as a BufferedImage

tagImg = source.getAsBufferedImage();

tagImg = source.getAsBufferedImage();

有关.PDF-出口(通过iText的),我需要它作为 java.awt.Image中

For .pdf-Export (via iText) I need it as java.awt.Image

谢谢!

推荐答案

java.awt.image.BufferedImage中是已经的 java.awt.Image中,所以你不需要任何铸造或转产。您可以使用的BufferedImage代替图像。

java.awt.image.BufferedImage is already a subclass of java.awt.Image, so you shouldn't need any casting or converting. You can use the BufferedImage in place of a Image.

您可以直接做到这一点:

You can do directly this:

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

这篇关于如何投/转换一个BufferedImage成图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆