问题描述
这个问题已经被问及曾出现过的,我现在用的是很版毕加索做了一个承诺:如何发送一个圆形的位图使用毕加索的ImageView的?我是很新的毕加索和唯一的事情我已经使用迄今
The question had been asked and there had been a promise made for the very version of Picasso that I am using: How do I send a circular bitmap to an ImageView using Picasso? I am very new to Picasso and only thing I have used so far is
Picasso.with(context).load(url).resize(w, h).into(imageview);
我已经找到 https://gist.github.com/julianshen/5829333 ,但我不知道怎么样将其与线结合上面以非ackward方式
I have already found https://gist.github.com/julianshen/5829333 but I am not sure how to combine it with the line above in a non-ackward way.
推荐答案
研究了一下之前因为有答案avaiable.Anyhow,按照此链接并仔细阅读,了解如何使用它 -
Research a bit before as there are answers avaiable.Anyhow, follow This Link and read it carefully to know how to use it-
试试这个---
import com.squareup.picasso.Transformation;
public class CircleTransform implements Transformation {
@Override
public Bitmap transform(Bitmap source) {
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
if (squaredBitmap != source) {
source.recycle();
}
Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
BitmapShader shader = new BitmapShader(squaredBitmap,
BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
paint.setShader(shader);
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
squaredBitmap.recycle();
return bitmap;
}
@Override
public String key() {
return "circle";
}
}
然后简单地套用什么样子---
then simply apply it like---
Picasso.with(activity).load(mayorShipImageLink).transform(new CircleTransform()).into(ImageView);
这篇关于机器人:创建圆形图像与毕加索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!