posts - 496,comments - 227,trackbacks - 0
BufferedImage img = ImageIO.read(file);
                
int h = img.getHeight();
                
int w = img.getWidth();
                
                
if(h>=96 && w >=96){
                    
int nw = 96;
                    
int nh = (nw * h) / w;
                    
if(nh>96) {
                        nh 
= 96;
                        nw 
= (nh * w) / h;
                    }
                    ByteArrayOutputStream out 
= new ByteArrayOutputStream();
                    BufferedImage dest 
= new BufferedImage(nw, nh,BufferedImage.TYPE_4BYTE_ABGR);
                    dest.getGraphics().drawImage(img,
0,0,nw, nh,null);
                    GifEncoder.encode(dest, out);
                    
//ImageIO.write(dest, "gif", out);
                    imageThumbnail = out.toByteArray();
                }
                
else{
                    imageThumbnail 
= imageData;
                }
下载相关的包:http://www.blogjava.net/Files/wangxinsh55/gif89.zip
http://www.blogjava.net/Files/wangxinsh55/gif4j.zip
posted on 2009-08-21 12:53 SIMONE 阅读(502) 评论(0)  编辑  收藏 所属分类: JAVA

只有注册用户登录后才能发表评论。


网站导航: