ITeye博客

android对大图片压缩的方法

Darar · 2011-09-30 13:39 · android技术文章 · 移动开发 · Markdown

像新浪微博一样,把本地的照片进行压缩然后发。 andriod提供了一些方法如下: 压缩图片质量:
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, fos);
其中的quality为0~100, 可以压缩图片质量, 不过对于大图必须对图片resize

这个是等比例缩放: bitmap = Bitmap.createScaledBitmap(bitmap, width, height, false);

这个是截取图片某部分: bitmap = Bitmap.createBitmap(bitmap, x, y, width, height);

这几个方法都是针对Bitmap的, 不过鉴于Bitmap可以从file中读取, 也可以写入file.

这是我知道Android自带库里中唯一可以缩放和压缩的图片方法.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。