我从我的数据库中加载了一个bitmap
图片,但是我正在拉伸我的图像,它返回了我blur
图像,我收到了此错误
“位图太大而无法上传到纹理
(3000x1547, max=2048x2048)
”
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = calculateInSampleSize(options, 3000 ,
1574);
Display mDisplay = (getActivity()).getWindowManager()
.getDefaultDisplay();
bitmap = BitmapFactory.decodeByteArray(map, 0, map.length, options);
image.setImageBitmap(Bitmap.createScaledBitmap(bitmap,2048,1500,
false));
public static int calculateInSampleSize(BitmapFactory.Options options,
int d, int e) {
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > e || width > d) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
// Calculate the largest inSampleSize value that is a power of 2 and
// keeps both
// height and width larger than the requested height and width.
while ((halfHeight / inSampleSize) > e
&& (halfWidth / inSampleSize) > d) {
inSampleSize *= 2;
}
}
return inSampleSize;
}