合并两个单通道 BufferedImage 对象
我有组合两个 BufferedImage 对象的代码,每个对象代表一个单独的颜色通道(红色和蓝色)。目前我正在做:
int p, q, g, b;
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
p = img0.getRGB(x, y) & 0xff00;
q = img1.getRGB(x, y) & 0xff;
fused.setRGB(x, y, p | q);
}
}
但是,对于 2000x2000 图像来说,这相当慢。有没有更快的方法通过 Java2D 或 JAI API 来做到这一点?我已经阅读了 AlphaComposite 类,但这似乎是基于透明度组合图像,而不是实际合并通道。
任何指示将不胜感激。
I have code that combines two BufferedImage objects, each one representing a separate color channel (red and blue). Currently I am doing:
int p, q, g, b;
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
p = img0.getRGB(x, y) & 0xff00;
q = img1.getRGB(x, y) & 0xff;
fused.setRGB(x, y, p | q);
}
}
However, this is rather slow for a 2000x2000 image. Is there a faster way to do this via the Java2D or JAI API's? I've read up on the AlphaComposite class, but that seems to combine images based on transparency, rather than actually merge channels.
Any pointers would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论