在Java中组合多个图像
我有这几个图像,需要使用 java 中的 BufferedImage 进行组合。程序的逻辑是这样的: 用户将被要求输入数据(5次),然后输入的值将生成图像(我已经完成了这部分的编码)。我的问题是如何将它们组合成一张图像。谢谢!
I have these several images which I need to be combined using BufferedImage in java. The logic of the program is this:
The user will be asked to input data (5 times) then the inputted value will be generated to image (I'm done coding with this part). My problem is how can I Combine them into one image only. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建另一个新图像。根据您想要组合图像的方式,您有两种可能性:
BufferedImage
上调用getGraphics()
并使用drawImage()
多次将其他图像绘制到新创建的图像中(例如,使用您之前创建的所有图像创建平铺图像)You can create another new image. Depending on how you would like to combine the images you have two possibilities:
getGraphics()
on the newly createBufferedImage
and usedrawImage()
multiple times to draw your other images into the newly created one (for example to create a tiled image with all the images you create beforehand)getRaster()
on the newly createBufferedImage
and use the methods of this object to draw information from your other images into this image (this way you can achieve any blend effects you might need)