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://m.tkk7.com/Files/wangxinsh55/gif89.zip
http://m.tkk7.com/Files/wangxinsh55/gif4j.zip
posted on 2009-08-21 12:53
SIMONE 閱讀(572)
評論(0) 編輯 收藏 所屬分類:
JAVA