imageview中的Android照片,质量差

时间:2014-09-12 08:17:12

标签: android image photo

我允许用户拍照,然后我将这张照片设置为图片视图。

这是我的imageview代码:

        <ImageView 
        android:id="@+id/photo1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        android:layout_marginBottom="2dp" />

我的代码将照片放在此imageview中:

        imgPhoto1.setImageBitmap(btmap);

我的问题是,照片​​显示模糊.....

如何才能获得“正确”的质量?

我试着用这个:

getWindow().setFormat(PixelFormat.RGBA_8888);

但它什么都没改变。

THX,

编辑:拜托,如果可能的话,我正在寻找一个不使用图书馆的解决方案,它仅用于两个图像视图..

编辑2:好的,没有库似乎是不可能的,因为我的图像占据了屏幕上的所有可用空间。

4 个答案:

答案 0 :(得分:2)

此功能解决了ImageView中图像质量不佳的问题:

public static Bitmap getBitmapFromResources(Resources resources, int resImage) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = false;
    options.inDither = false;
    options.inSampleSize = 1;
    options.inScaled = false;
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;

    return BitmapFactory.decodeResource(resources, resImage, options);
}

imageView.setImageBitmap(getBitmapFromResources(getResources(), R.drawable.image));

答案 1 :(得分:0)

不是加载位图而是使用通用图像加载器或毕加索:

Android-Universal-Image-Loader

picasso

Why use Android Picasso library to download images?

答案 2 :(得分:0)

您也可以使用AndroidQuery。它还允许您加载图像异步。我从未遇到质量问题。它非常易于使用,还允许您缓存图像。

https://code.google.com/p/android-query/

答案 3 :(得分:0)

更改您的imgview宽度和高度样式

<ImageView 
        android:id="@+id/photo1"
        <!--android:layout_width="match_parent"-->
        <!--android:layout_height="match_parent"-->
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        android:layout_marginBottom="2dp" />

希望有所帮助

相关问题