如何将2个图像连接在一起(不合并)

时间:2011-12-18 15:41:48

标签: java image connect

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

enter image description here

如何使用Java源代码

执行此操作

我可以合并 但我不能像这个图片那样连接

3 个答案:

答案 0 :(得分:1)

将每张图片放在ImageIcon中,然后将Icon放在JLabel中,然后将JLabels添加到使用{{1}的JPanel (2行,1列)。

答案 1 :(得分:1)

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

答案 2 :(得分:0)

        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"));