把二个图片合并起来,就是叠在一起,成为一个图片,有好办法吗?谢谢
分不多,绝对给分。

解决方案 »

  1.   

    // 两图片合成,自己设定合成位置
    public static void jpegSynthesis(File srcfile1, File srcfile2, int picw,
    int pich, int s1x, int s1y, int s1width, int s1height, int s2x,
    int s2y, int s2width, int s2height, String name) throws IOException {
    System.out.println(srcfile1);
    Image src1 = javax.imageio.ImageIO.read(srcfile1);
    Image src2 = javax.imageio.ImageIO.read(srcfile2);
    BufferedImage tag = new BufferedImage(picw, pich,
    BufferedImage.TYPE_INT_RGB);
    // tag.getGraphics().drawImage(,0,0,picw,pich,Color.WHITE,null);
    tag.getGraphics().drawImage(src1, s1x, s1y, s1width, s1height, null);
    tag.getGraphics().drawImage(src2, s2x, s2y, s2width, s2height, null);
    FileOutputStream out = new FileOutputStream(name); // 输出到文件流
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    encoder.encode(tag);
    System.out.println("两副图片合成完毕!" + picw + "*" + pich);
    out.close();
    }
      

  2.   

    这个处理JPG可以,但处理GIF不行,处理Gif时,输出的图像都变了。