java程序处理两张图片合并为一张图片


更多实例请访问 http://www.walkerjava.com/thread-136-1-1.html

public class Test4 {
     public static void main(String[] args) throws Exception {
           InputStream is1 = new FileInputStream("d:\\image\\psb.jpg");
           InputStream is2 = new FileInputStream("d:\\image\\walkerjava.png");
           BufferedImage bi1 = ImageIO.read(is1);
           BufferedImage bi2 = ImageIO.read(is2);
           Graphics g = bi1.getGraphics();
           g.drawImage(bi2, bi1.getWidth() - bi2.getWidth() - 10, bi1.getHeight()
                      - bi2.getHeight() - 14, null);
更多实例请访问 http://www.walkerjava.com/thread-136-1-1.html
           OutputStream out = new FileOutputStream("d:\\image\\out2.jpg");
           JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(out);
           enc.encode(bi1);
           is1.close();
           is2.close();
           out.close();
     }
}

更多实例请访问 http://www.walkerjava.com/thread-136-1-1.html


你可能感兴趣的:(图片,java程序,合并图片)