-->

Loading images by Glide spoil image quality

2019-08-17 08:02发布

问题:

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

回答1:

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.



回答2:

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"