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

问题描述 投票:0回答:2

我建立简单的画廊。我用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);
android image gallery android-glide image-quality
2个回答
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必须有widthheightWRAP_CONTENT值。


0
投票

请试试这个:

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

Imageview属性设置android:adjustViewBounds="true"

© www.soinside.com 2019 - 2024. All rights reserved.