/**
* 压缩收藏表情,最大边压到150
*/
public static Bitmap getFaceBitmapFronPath(Context context, String filePath)
throws FileNotFoundException {
if (null == filePath) {
return null;
}
Options options = new Options();
options.inJustDecodeBounds = true;
Bitmap temp = BitmapFactory.decodeFile(filePath, options);
options.inJustDecodeBounds = false;
int actualWidth = options.outWidth;
int actualHeight = options.outHeight;
int desiredWidth = actualWidth;
int desiredHeight = actualHeight;
if (actualWidth > 150 && actualHeight > 150) {
if (actualWidth > actualHeight) {
desiredWidth = (int) (actualWidth * ((150 *1.0) / actualHeight));
desiredHeight = 150;
} else {
desiredHeight = (int) (actualHeight * ((150 *1.0)/ actualWidth));
desiredWidth = 150;
}
}
options.inSampleSize = findBestSampleSize(actualWidth, actualHeight,
desiredWidth, desiredHeight);
temp = BitmapFactory.decodeFile(filePath, options);
temp = Bitmap.createScaledBitmap(temp, desiredWidth,
desiredHeight, true);
return temp;
}
BitmapUtil.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:GCSApp
作者:
评论列表
文章目录