如何融合两个图像 [英] How to blend two image
本文介绍了如何融合两个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将两张图片混合在一起,比例为4:1
结果应该是这样的
所以有任何想法吗 ?
提前致谢
解决方案
这个问题很模糊,但您可以使用2D图形API
查看
了解更多详情.. 。
I want to blend two images together with a ratio of 4:1
the result should be something like this
So any ideas ? Thanks in advance
解决方案
The question is vague, but you could use the 2D Graphics API
Take a look at 2D Graphics and Compositing Graphics in particular...
So using the following images (base on left, overlay on right)
try {
BufferedImage base = ImageIO.read(new File("base.jpg"));
BufferedImage overlay = ImageIO.read(new File("overlay.jpg"));
Graphics2D g2d = base.createGraphics();
g2d.setComposite(AlphaComposite.SrcOver.derive(0.5f));
int x = (base.getWidth() - overlay.getWidth()) / 2;
int y = (base.getHeight() - overlay.getHeight()) / 2;
g2d.drawImage(overlay, x, y, null);
g2d.dispose();
ImageIO.write(base, "jpg", new File("Blended.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
Resulting in...
Take a look at...
for more details...
这篇关于如何融合两个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文