如何在Java中将多个图像合并为一个图像(垂直平铺的图像)

时间:2018-05-23 15:24:50

标签: java image merge javax.imageio

我有一张图片列表。我想将它们合并为一个图像,以便它们在新图像中垂直排列。研究向我指出了这段代码,但努力使它们对齐

BufferedImage result = new BufferedImage(
                    width, height, //work these out
                    BufferedImage.TYPE_INT_RGB);
                    Graphics g = result.getGraphics();

                    for(String image : imgFiles){
                        BufferedImage bi = ImageIO.read(new File(image));
                        g.drawImage(bi, x, y, null);
                        x += 256;
                        if(x > result.getWidth()){
                            x = 0;
                            y += bi.getHeight();
                        }
                    }

0 个答案:

没有答案