通过Glide破坏图像质量加载图像 [英] Loading images by Glide spoil image quality
问题描述
我建立了一个简单的画廊.我使用Glide加载照片.在滑行加载的图像上看起来有点条纹(像素似乎可见).
我尝试加载更改后的格式RGB_565/ARGB_8888
的照片,但使用了.dontTransform()
,但它看起来比原始照片差.
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.
我用来加载的代码:
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);
推荐答案
要使用Glide
加载原始图像,请使用以下代码:
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);
}
});
请记住,由于设备的屏幕分辨率,浏览器中的图片在设备上可能看起来有所不同.使用此方法,您将可以使用Bitmap
对象检查像素.
另外,请记住,您的ImageView
必须具有width
和height
且具有WRAP_CONTENT
值.
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.
这篇关于通过Glide破坏图像质量加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!