【问题标题】:android - image quality is low when using glideandroid - 使用滑翔时图像质量很低
【发布时间】:2017-07-14 23:52:50
【问题描述】:

我是 android 开发的新手。在我的应用程序中,我有一个包含图像的horizontalScrollView。后来我一直在使用毕加索从 URL 加载图像。后来听说glide所以改用glide了,现在我的图片加载速度很快但是图片质量太低了。

代码如下

//load image from URL 1.1
        ivImageFromURL = (ImageView) findViewById(R.id.videoconwmimage);
        Glide.with(this).load("http://imgur.com/KtfpVUb.png").into(ivImageFromURL);

【问题讨论】:

  • 看起来你的图片不是高分辨率图片
  • 当我使用毕加索时,图像看起来很好......

标签: android image android-glide


【解决方案1】:

如果您使用的是 Glide v4,那么在发出 Glide 请求时,请更改

Glide.with(imageView).load(url).into(imageView);

到

Glide.with(imageView).load(url)
    .apply(new RequestOptions()
            .fitCenter()
            .format(DecodeFormat.PREFER_ARGB_8888)
            .override(Target.SIZE_ORIGINAL))
    .into(imageView);

这对我有用,而无需向清单中添加任何内容。在 XML 中将 android:adjustViewBounds="true" 添加到您的 ImageView 可能会有所帮助。类是

import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;

【讨论】:

  • 我只用override(Target.SIZE_ORIGINAL)就成功了。为什么你打电话给fitCenter() 和format()?我也只用dontTransform() 就成功了。
  • 这个解决了我的问题。
  • 也许我们应该使用dontTransform() 而不是fitCenter()? - github.com/bumptech/glide/issues/531#issuecomment-120012741
【解决方案2】:

Glide 使用 RGB_565 不会占用太多内存。如果您觉得默认设置不合适,您可以使用 Glide.Builder 并将 builder.setDecodeFormat(DecodeFormat.ALWAYS_ARGB_8888); 设置为您的首选配置。

https://github.com/bumptech/glide/wiki/Configuration查看链接。

【讨论】:

    【解决方案3】:

    这是因为 Glide 默认位图格式设置为 RGB_565,因为它 与 Picasso 使用的 ARGB_8888 相比,仅消耗 50% 的内存占用。

    您可以通过以下更改来修复它:

    public class GlideConfiguration implements GlideModule {
    
        @Override
        public void applyOptions(Context context, GlideBuilder builder) {
            // Apply options to the builder here.
            builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
        }
    
        @Override
        public void registerComponents(Context context, Glide glide) {
            // register ModelLoaders here.
        }
    }
    

    并将以下内容添加到您的清单中:

    <meta-data android:name="com.inthecheesefactory.lab.glidepicasso.GlideConfiguration"
                android:value="GlideModule"/>
    

    更多详情请访问here

    【讨论】:

      【解决方案4】:

      请查看此链接

      图像质量较低的滑行加载

      https://github.com/bumptech/glide/issues/1227

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-12-12
        • 2016-02-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多