【问题标题】:How can I set the density of images loaded with Picasso?如何设置用毕加索加载的图像的密度?
【发布时间】:2016-04-19 23:35:09
【问题描述】:

我用毕加索加载的图像似乎使用了DENSITY_NONE 的密度值。在显示加载的图像之前,我需要进行哪些更改才能让 Picasso 在加载的图像上调用 .setDensity(160)

【问题讨论】:

    标签: android bitmap picasso pixel-density


    【解决方案1】:

    基于another Picasso solution to resize images 我实现了一个自定义转换对象,它将图像的密度设置为我自己的常数:

    Transformation changeDensity = new Transformation()
    {
        @Override public Bitmap transform(Bitmap source)
        {
            source.setDensity(160);
            return source;
        }
    
        @Override public String key()
        {
            return "density";
        }
    };
    
    // …later…
    
    Picasso
        .with(context)
        .load(imageUri)
        .transform(changeDensity)
        .into(imageView);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-29
      • 2016-04-07
      • 2020-09-03
      相关资源
      最近更新 更多