【发布时间】:2015-04-21 18:50:57
【问题描述】:
我正在 Android 中开发一个使用维纳滤镜去模糊图像的应用。一旦我对输入图像(模糊图像)进行了必要的计算,我就需要使用新的 RGBA 值创建一个新的未模糊图像。我已经成功地用 Java 编写了这个代码,但找不到与我在 Android 中创建图像的方式相同的解决方案。我知道您必须在 Android 中使用位图,但由于无法使用 BufferedImage/Raster/WritableRaster,因此无法找到如何设置示例()。我的Java代码如下,
final BufferedImage unblurredImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final WritableRaster unblurredRaster = unblurredImage.getRaster();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
unblurredRaster.setSample(x, y, 0, (rgb[x + y * width] >> 16) & 0xFF); // red
unblurredRaster.setSample(x, y, 1, (rgb[x + y * width] >> 8) & 0xFF); // green
unblurredRaster.setSample(x, y, 2, rgb[x + y * width] & 0xFF); // blue
unblurredRaster.setSample(x, y, 3, (rgb[x + y*width] >> 24) & 0xFF); // alpha
}
}
return unblurredImage;
【问题讨论】:
标签: java android bufferedimage raster bitmapimage