/**
* 传递一个创建小图的路径
*/
public static void _CreateSmallByLocalPath(String str) {
int last = str.lastIndexOf(".");
String path = str.substring(0, last);
StringBuffer sb = new StringBuffer(path);
sb.append("_s.png");
Bitmap bitmap = BitmapFactory.decodeFile(str);
Bitmap bitmap1 = ThumbnailUtils.extractThumbnail(bitmap, 608, 342);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap1.compress(Bitmap.CompressFormat.PNG, 100, baos);
BufferedOutputStream stream = null;
try {
//得到缩略图
File file = new File(sb.toString());
FileOutputStream fstream = new FileOutputStream(file);
stream = new BufferedOutputStream(fstream);
stream.write(baos.toByteArray());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
Android 如何对本地图片进行缩略并重新命名
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。