1

The images I load with Picasso seem to use a density value of DENSITY_NONE. What do I have to change to make Picasso call .setDensity(160) on the loaded images before they are displayed?

Grzegorz Adam Hankiewicz
  • 7,349
  • 1
  • 36
  • 78

1 Answers1

1

Basing myself on another Picasso solution to resize images I implemented a custom transformation object which sets the density of images to a constant of my own:

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);
Community
  • 1
  • 1
Grzegorz Adam Hankiewicz
  • 7,349
  • 1
  • 36
  • 78