首页 > 解决方案 > 如何在Java中将多张图像合并为一张图像(垂直平铺的图像)

问题描述

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

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();
                        }
                    }

标签: javaimagemergejavax.imageio

解决方案


推荐阅读