通过Glide加载图像破坏图像质量

时间:2017-05-18 11:56:50

标签: android image gallery android-glide image-quality

我建立简单的画廊。我用Glide加载我的照片。看起来像滑行加载的图像是某种条纹(像素似乎是可见的)。 我尝试使用更改后的格式RGB_565/ARGB_8888加载照片并使用.dontTransform()但仍然看起来比原始照片更糟糕。

我用来加载的代码:

ImageView photoDetails;
photoDetails = (ImageView)findViewById(R.id.imageDetails);
Glide.with(this)
        .load(pictureFile) //path to picture
        .asBitmap()
        .format(DecodeFormat.PREFER_ARGB_8888)
        .dontTransform()
        .into(photoDetails);

2 个答案:

答案 0 :(得分:0)

要使用Glide加载原始图像,请使用以下代码:

  Glide.with(view.getContext())
                    .load(pictureFile)
                    .asBitmap()
                    .into(new SimpleTarget<Bitmap>(Target.SIZE_ORIGINAL,Target.SIZE_ORIGINAL) {
                        @Override
                        public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
                            imageView.setImageBitmap(resource);
                        }
                    });

请注意,由于设备的屏幕分辨率,浏览器中的图片在设备上可能会有所不同。使用此方法,您将能够使用Bitmap对象检查像素。 另请注意,您的ImageView必须widthheight且值WRAP_CONTENT

答案 1 :(得分:0)

请尝试这个

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_margin="2dp"

Imageview属性集android:adjustViewBounds="true"

相关问题