gpt4 book ai didi

安卓 : Image qulity decreased using ImageLoader

转载 作者:行者123 更新时间:2023-11-29 15:26:54 26 4
gpt4 key购买 nike

我正在使用 https://github.com/thest1/LazyList用于图像缓存。我必须全屏显示图像。但图像质量有很大损失。我必须更改哪些代码才能获取原始图像。提前致谢。

最佳答案

在ImageLoader类中寻找这个方法,

  private Bitmap decodeFile(File f){
try {
//decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f),null,o);

//Find the correct scale value. It should be the power of 2.
final int REQUIRED_SIZE=70;
int width_tmp=o.outWidth, height_tmp=o.outHeight;
int scale=1;

while(true){
if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE)
break;
width_tmp/=2;
height_tmp/=2;
scale*=2;
}
//decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize=scale;
return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
} catch (FileNotFoundException e) {}
return null;
}

并从此方法中删除以下行,

while(true){
if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE)
break;
width_tmp/=2;
height_tmp/=2;
scale*=2;
}

这将确保您的图像根本不会缩放。

But you have to keep in mind that, your app is vulnerable to OOM if you do this.

关于安卓 : Image qulity decreased using ImageLoader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11578452/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com