2010-11-23 119 views
3

我想将BufferedImage转换为java.awt.Image如何将BufferedImage转换成图像?

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

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

然后我保存它作为一个对象的属性作为BufferedImage

tagImg = source.getAsBufferedImage();

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

谢谢!

回答

7

java.awt.image.BufferedImage已经是java.awt.Image的子类,所以你不应该需要任何铸件或转换。您可以使用BufferedImage来代替Image。

你可以直接在此:

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