我一直在使用 Java 中的一些成像功能,试图将一张图像叠加在另一张图像上。像这样:
BufferedImage background = javax.imageio.ImageIO.read(
new ByteArrayInputStream(getDataFromUrl(
"https://www.google.com/intl/en_ALL/images/logo.gif"
))
);
BufferedImage foreground = javax.imageio.ImageIO.read(
new ByteArrayInputStream(getDataFromUrl(
"https://upload.wikimedia.org/wikipedia/commons/e/e2/Sunflower_as_gif_small.gif"
))
);
WritableRaster backgroundRaster = background.getRaster();
Raster foregroundRaster = foreground.getRaster();
backgroundRaster.setRect(foregroundRaster);
基本上,我试图在此叠加: https
://upload.wikimedia.org/wikipedia/commons/e/e2/Sunflower_as_gif_small.gif:https
: //www.google.com/intl/en_ALL/images/logo .gif
产品显示为:http: //imgur.com/xnpfp.png
从我看到的例子来看,这似乎是合适的方法。我错过了一步吗?有没有更好的方法来处理这个?谢谢你的回复。