全屏显示图像 - 失去优质的机器人

时间:2013-07-25 05:22:05

标签: android bitmap android-imageview android-fullscreen

我正在尝试全屏显示图像但似乎图像质量下降。我从URL获取图像,我下载它,当我显示图像时,它看起来很糟糕。我得到的图像是高分辨率的,所以我不知道问题是什么?

这是我的布局,我正在显示图像:

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/full_screen_banner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name" />

这是java代码:

imageViews.put(imageView, url);
Bitmap bitmap = memoryCache.get(url);
if (bitmap != null)
    imageView.setImageBitmap(bitmap);

1 个答案:

答案 0 :(得分:1)

如果您正在使用图像加载器,请转到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 = 100;
        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;
}