您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何将多个PNG合并为一个大PNG文件?

如何将多个PNG合并为一个大PNG文件?

创建要写入的大图像。根据所需的行数和列数来确定其尺寸。

    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"));
其他 2022/1/1 18:14:38 有568人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶