0

只是我有一个图像的光栅,我想制作bufferedImage它。

Raster raster = someObject.getAsRaster();
BufferedImage bi = ?

如何制作bufferedImage合适colorModel的图像以正确显示图像?
谢谢!

4

2 回答 2

2
Raster raster = ...; // Your raster
ColorModel colorModel = ...; // A suitable color model (see comment section)

WritableRaster writableRaster = raster.createCompatibleWritableRaster();
writableRaster.setDataElements(0, 0, raster);
BufferedImage image = new BufferedImage(colorModel, writableRaster, colorModel.isAlphaPremultiplied(), null);
于 2013-08-08T08:47:46.970 回答
0

使用构造函数

BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties) 

如果您提供有关如何获取栅格的更多信息,我会更有帮助

于 2013-08-07T11:31:55.530 回答