怎样写个程序实现把n张JPG格式的图片制作成一个 gif 文件 
我使用了 AnimatedGifEncoder 类,发现生成的 gif 文件大小扩大了 2.5 倍 , 如二个 10 的文件,生成的 gif 大小达到 50k 还多,肯定是有问题的。 谁能实现这个功能, 生成的文件越小越好(不能牺牲画质)。 持方法类似的定义为: void makeGif(String gifFileName,String []jpgFileList,int showTime,int repeatShowTimes) 我的办法: AnimatedGifEncoder e = new AnimatedGifEncoder(); 
e.start(jpgFileList[i]); 
e.setDelay(showTime);   
e.setRepeat(repeatShowTimes);   
for(int i=0;i<jpgFileList.length;i++){ 
   e.addFrame(ImageIO.read(new File(jpgFileList[i]))); 

e.finish(); 可是生成的 gif 文件太大了。 需要 AnimatedGifEncoder 代码的可找我,或者在网络收搜索下,很多的。 

解决方案 »

  1.   

    我也在解决这个问题,大概原始的jpg图片有450张左右,总大小在1.4M,但合成一个GIF后大小是7M多。
    有什么好方法大家都讨论一下。
      

  2.   

     protected void getImagePixels() {
      int w = image.getWidth();
      int h = image.getHeight();
      int type = image.getType();
      if ((w != width)
       || (h != height)
       || (type != BufferedImage.TYPE_3BYTE_BGR)) {
       // create new image with right size/format
       BufferedImage temp =
        new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);

       Graphics2D g = temp.createGraphics();
       g.drawImage(image, 0, 0, null);
       image = temp;
      }
      pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
     }
    是不是这个转化的原因,而且out中也写了一些别的信息
      

  3.   

    谁研究过 jai , 请专家回答