【问题标题】:How to bring 2 image for connect together (not merge)如何将 2 个图像连接在一起(不合并)
【发布时间】:2011-12-18 15:41:48
【问题描述】:

http://image.ohozaa.com/view/6fcjh

如何用 Java 源代码做到这一点

我可以合并 但我不能像这张照片那样连接它

【问题讨论】:

    标签: java image connect


    【解决方案1】:

    另一种方法是将多个图标组合成一个图标。见Compound Icon

    【讨论】:

    • 这是一个不错的解决方案。
    【解决方案2】:

    将每个图像放入ImageIcon,然后将每个Icon 放入JLabel,然后将JLabels 添加到使用GridLayout(2, 1)JPanel(2 行,1 列)。

    【讨论】:

    • 似乎是最简单的解决方案。
    【解决方案3】:
            File path = new File("images");
    
            BufferedImage image = ImageIO.read(new File(path, "1 (1).jpg"));
            BufferedImage overlay = ImageIO.read(new File(path, "1 (2).jpg"));
    
            int w = image.getWidth();
            int h = image.getHeight()+ overlay.getHeight();
            BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    
            Graphics g = combined.getGraphics();
            g.drawImage(image, 0, 0, null);
            g.drawImage(overlay, 0, image.getHeight(), null);
    
            ImageIO.write(combined, "PNG", new File(path, "combined 2.png"));
    

    【讨论】:

    • 代码答案最好带注释。请在您的答案中添加一些上下文。
    猜你喜欢
    • 1970-01-01
    • 2013-01-17
    • 2020-05-29
    • 2019-10-03
    • 2011-06-25
    • 1970-01-01
    • 2019-08-12
    • 1970-01-01
    • 2016-12-02
    相关资源
    最近更新 更多