下载影像看起来非常模糊 [英] Downloaded Image Appears very blurry
问题描述
我下载的图像使用以下这个优秀文章。我自己的形象我使用的是谷歌地图的静态图像是300x400。我一直拨弄几的设置,并扩大其在屏幕上,以填补,但它只是似乎很模糊。
I downloaded an image to use following this excellent article. My own image I'm using is a google map static image that is 300x400. I've fiddle with a few of the settings and have expanded it to fill across the screen, however it just appears very blurry.
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0dp"
android:layout_y="0dp"
android:adjustViewBounds="true"
android:clickable="false"
android:gravity="center_vertical"
android:longClickable="false"
android:scaleType="fitCenter" />
这是我在屏幕XML布局。这是一个常见的问题?我做了一个很好的搜索,但没有找到答案。是不是300x400 Android的一个很好的资源?
That is what I have in the screen xml layout. Is this a common problem? I did a good search and couldn't find an answer. Is 300x400 not a good res for android?
推荐答案
我找到了原因,他们是低,图像加载器类有一个内置的COM pression:
I found the reason why they were low, the image loader class had a built in compression:
//decodes image and scales it to reduce memory consumption
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;
}
所以你留下了
所以才删除此部分:
So just remove this part so you are left with:
//decodes image and scales it to reduce memory consumption
private Bitmap decodeFile(File f){
try {
return BitmapFactory.decodeStream(new FileInputStream(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return null;
}
清晰的图像。
这篇关于下载影像看起来非常模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!