1

I have a fairly high resolution image which I'm getting from a remote URL and scaling down using Picasso. I've realized that at certain resolutions I get a pixelated image displayed onscreen.

The interesting part is that if I increase the resolution of the image in Picasso and allow ImageView to scale it down, I get no jagged edges from a lower resolution version of the image.

My first thought is that there is some under-sampling happening, perhaps in Picasso's inSampleSize calculations, here: https://github.com/square/picasso/blob/master/picasso/src/main/java/com/squareup/picasso/RequestHandler.java#L155

Is there any way to override the inSampleSize to prevent Picasso from giving me a lower-resolution image?
I've seen implementations such as this: https://stackoverflow.com/a/4250279 which keep the inSampleSize to a power of 2, as they should be.

Here's my basic implementation: (Leads to a pixelated image)

public class myClass extends ImageView {

...

   RequestCreator mRequestCreator = Picasso.load(photoUrl);
   mRequestCreator.fit().into(this);
}

This leads to a non-pixelated image:

public class myClass extends ImageView {

...

  RequestCreator mRequestCreator = Picasso.load(photoUrl);
  mRequestCreator.resize(getWidth()*2, getHeight()*2);
  mRequestCreator.into(this);

  this.setScaleType(CENTER_CROP)
}
Community
  • 1
  • 1
ccpmark
  • 1,005
  • 1
  • 10
  • 11

0 Answers0