将BufferedImages数组编译为Single BufferedImage

时间:2016-12-17 00:39:58

标签: java user-interface paint

使用Two-Dimensional Array BufferedImages,有两种方法:从BufferedImage创建单个大array或使用个人elements因此,以及如何使用paintComponent()作为背景来实现此目的

1 个答案:

答案 0 :(得分:0)

您发布的代码不完整,与您提出的要求几乎没有关系。这就是说,假设图像都具有相同的大小,这应该有效:

paintComponent(Graphics g) {
  int x = 0;
  int y = 0;
  int w = worldMap[0][0].getWidth();
  int h = worldMap[0][0].getHeight();
  for(int r=0; r<WorldMap.length; r++) {
    for(int c=0; c<WorldMap[r].length; c++) {
      g.drawImage(WorldMap[r][c], x, y, this);
      x += w;  
    }
    y += h;
    x = 0;
  }
}
相关问题