Loading images by Glide spoil image quality

2019-08-17 07:54发布

I build simple gallery. I load my photos using Glide. It looks like on images loaded by glide is some kind of streak (pixels seems to be visible). I tried to load photo with changed Format RGB_565/ARGB_8888 and I used .dontTransform() but still it looks worse than original photo.

Code I use to load :

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条回答
走好不送
2楼-- · 2019-08-17 08:10

To load the original image using Glide I use the code below:

  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);
                        }
                    });

Remember that the picture in browser may look different on the device due to the screen resolution of your device. Using this method you will be able to check the pixels using the Bitmap object. Also, keep in mind that your ImageView must have width and height with WRAP_CONTENT value.

查看更多
放荡不羁爱自由
3楼-- · 2019-08-17 08:17

Please try this one:

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

Imageview property set android:adjustViewBounds="true"

查看更多
登录 后发表回答