简体   繁体   English

图像不清晰 - Picasso Android

[英]Images are not clear - Picasso Android

I'm using Picasso for downloading images from URL and putting in ImageView. 我正在使用Picasso从URL下载图像并放入ImageView。 Images are rectangle, but my ImageViews are squares. 图像是矩形的,但我的ImageViews是正方形。 So I need to use some cropping, because I have spaces on top and bottom. 所以我需要使用一些裁剪,因为我在顶部和底部都有空格。

Without cropping the image is clear: 没有裁剪图像很清楚:

Picasso.with(context)
.load(left.get(pos).getImageName())
.into(ivFrontPageLeftImage);

图片

To fit inside and crop I'm using: 适合我正在使用的内部和裁剪:

Picasso.with(context)
.load(left.get(pos)
.getImageName())
.fit().centerInside()
.into(ivFrontPageLeftImage);

图片

But as you can see the image is not clear, it is blur. 但是你可以看到图像不清晰,它很模糊。 So how can I fit image inside the square (ImageView). 那么我如何在正方形(ImageView)中拟合图像。 Also image need to be clear, not blur? 图像还需要清晰,不要模糊吗?

I download this image, crop it with size 300 x 300 (to be square, i cut from left and right) and upload it. 我下载这个图像,裁剪尺寸为300 x 300(方形,我从左和右切割)并上传 I use this new image to put in ImageView: 我使用这个新图像放入ImageView:

Picasso.with(context)
.load("http://oi62.tinypic.com/29y61p3.jpg")
.fit().centerCrop()
.into(ivFrontPageLeftImage);

图片

As you can see image is clear and it is not blur. 正如您所看到的,图像清晰,并且不模糊。 How can I do this programmatically? 我该如何以编程方式执行此操作? Is it possible with Picasso, or I need other library to do this? 是否有可能与毕加索,或我需要其他图书馆这样做?

I can't comment on Lee's answer as I don't have enough reputation. 由于我没有足够的声誉,我无法评论李的回答。 But his answer was correct as I had the same issue. 但他的答案是正确的,因为我有同样的问题。 You can also set it in the ImageView object by doing the following: 您还可以通过执行以下操作在ImageView对象中进行设置:

imageView = (ImageView) view.findViewById(R.id.img);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

Apply center crop on your ImageView instead of the method you are now using. 在ImageView上应用中心裁剪,而不是您现在使用的方法。

<ImageView
    ...
    android:scaleType="centerCrop"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM