ume双井,动漫h吧,仪铭
java根据url抓取并生成缩略图
bis = new bufferedinputstream(i, 1024 * 4);
out = new bytearrayoutputstream();
int len = 0;
while ((len = bis.read(isbuffer)) != -1) {
out.write(isbuffer, 0, len);
}
out.close();
bis.close();
} catch (malformedurlexception e1) {
e1.printstacktrace();
return null;
} catch (ioexception e) {
e.printstacktrace();
}
if (out == null)
return null;
byte[] data = out.tobytearray();
bitmapfactory.options options = new bitmapfactory.options();
options.injustdecodebounds = true;
bitmapfactory.decodebytearray(data, 0, data.length, options);
options.injustdecodebounds = false;
int be = (int) (options.outheight / (float) sc);
if (be <= 0) {
be = 1;
} else if (be > 3) {
be = 3;
}
options.insamplesize = be;
bitmap bmp = null;
try {
bmp = bitmapfactory.decodebytearray(data, 0, data.length, options); // 返回缩略图
} catch (outofmemoryerror e) {
// todo: handle exception
system.gc();
bmp = null;
}
return bmp;
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
apollo与springboot集成实现动态刷新配置的教程详解
网友评论