创建要写入的大图像。根据所需的行数和列数来确定其尺寸。
BufferedImage result = new BufferedImage(
width, height, //work these out
BufferedImage.TYPE_INT_RGB);
Graphics g = result.getGraphics();
现在遍历您的图像并绘制它们:
for(String image : images){
BufferedImage bi = ImageIO.read(new File(image));
g.drawImage(bi, x, y, null);
x += 256;
if(x > result.getWidth()){
x = 0;
y += bi.getHeight();
}
}
最后将其写出到文件中:
ImageIO.write(result,"png",new File("result.png"));