Last active
December 15, 2015 08:59
-
-
Save duanhong169/5235223 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Bitmap decodeSampledBitmapFromDescriptor( | |
FileDescriptor fileDescriptor, int reqWidth, | |
int reqHeight, ImageCache cache) { | |
// 设置inJustDecodeBounds=true来获取图片的尺寸 | |
final BitmapFactory.Options options = new BitmapFactory.Options(); | |
options.inJustDecodeBounds = true; | |
BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options); | |
// 计算采样率 | |
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); | |
// 设置inJustDecodeBounds=false得到bitmap对象 | |
options.inJustDecodeBounds = false; | |
return BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment