毕加索的分辨率损失缩放图像

时间:2015-03-02 23:12:01

标签: java android imageview scaling picasso

我有一个相当高分辨率的图像,我从远程URL获取并使用Picasso缩小。我意识到在某些分辨率下我会在屏幕上显示像素化图像。

有趣的是,如果我在Picasso中提高图像的分辨率并允许ImageView将其缩小,我就不会从图像的较低分辨率版本中获得锯齿状边缘。

我的第一个想法是,在毕加索的inSampleSize计算中可能会发生一些欠采样,这里: https://github.com/square/picasso/blob/master/picasso/src/main/java/com/squareup/picasso/RequestHandler.java#L155

有没有办法覆盖inSampleSize以防止Picasso给我一张分辨率较低的图片?我见过这样的实现:https://stackoverflow.com/a/4250279 inSampleSize为2的幂,应该是。

这是我的基本实现: (导致像素化图像)

public class myClass extends ImageView {

...

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

这导致非像素化图像:

public class myClass extends ImageView {

...

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

  this.setScaleType(CENTER_CROP)
}

0 个答案:

没有答案
相关问题