首页 > 其他 > 详细

Bitmap二次采样(处理图片过大的问题)

时间:2016-05-08 19:46:40      阅读:109      评论:0      收藏:0      [点我收藏+]

private Bitmap createImageThumbnail(String filePath, int newHeight,

int newWidth) {

BitmapFactory.Options options = new BitmapFactory.Options();

options.inJustDecodeBounds = true;

BitmapFactory.decodeFile(filePath, options);

int oldHeight = options.outHeight;

int oldWidth = options.outWidth;

// Log.i(TAG, "高度是:" + oldHeight + ",宽度是:" + oldWidth);

int ratioHeight = oldHeight / newHeight;

int ratioWidth = oldWidth / newWidth;

options.inSampleSize = ratioHeight > ratioWidth ? ratioWidth

: ratioHeight;

options.inPreferredConfig = Config.RGB_565;

options.inJustDecodeBounds = false;

Bitmap bm = BitmapFactory.decodeFile(filePath, options);

// Log.i(TAG, "高度是:" + options.outHeight + ",宽度是:" + options.outWidth);

return bm;

}

Bitmap二次采样(处理图片过大的问题)

原文:http://www.cnblogs.com/zhangminghan/p/5471230.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!