For something like below, the code is given
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Shader;
import sample.R;
public class BubbleTransformation implements com.squareup.picasso.Transformation {
private static final int outerMargin = 5;
private final int margin; // dp
// margin is the board in dp
public BubbleTransformation(final int margin) {
this.margin = margin;
}
@Override
public Bitmap transform(final Bitmap source) {
Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
Paint paintBorder = new Paint();
paintBorder.setColor(Color.DKGRAY);
paintBorder.setStrokeWidth(margin);
canvas.drawRoundRect(new RectF(outerMargin, outerMargin, source.getWidth() - outerMargin, source.getHeight() - outerMargin), 0, 0, paintBorder);
Paint trianglePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
trianglePaint.setStrokeWidth(2);
trianglePaint.setColor(Color.DKGRAY);
trianglePaint.setStyle(Paint.Style.FILL_AND_STROKE);
trianglePaint.setAntiAlias(true);
Path triangle = new Path();
triangle.setFillType(Path.FillType.EVEN_ODD);
triangle.moveTo(outerMargin, source.getHeight() / 2);
triangle.lineTo(source.getWidth()/2,source.getHeight());
triangle.lineTo(source.getWidth()-outerMargin,source.getHeight()/2);
triangle.close();
canvas.drawPath(triangle, trianglePaint);
final Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
canvas.drawRoundRect(new RectF(margin+outerMargin, margin+outerMargin, source.getWidth() - (margin + outerMargin), source.getHeight() - (margin + outerMargin)), 0, 0, paint);
if (source != output) {
source.recycle();
}
return output;
}
@Override
public String key() {
return "rounded";
}
}
String user_photo_url = "https://s3-ap-southeast-2.amazonaws.com/testuser.com/test_img.png";
Picasso.with(this)
.load(user_photo_url)
.resize(100,100)
.centerCrop()
.transform(new BubbleTransformation(5))
.into(mTarget);
Target mTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Marker driver_marker = mMap.addMarker(new MarkerOptions()
.position(new LatLng(12.841747, 77.651758))
.icon(BitmapDescriptorFactory.fromBitmap(bitmap))
.title("test")
.snippet("test address")
);
mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(12.841747, 77.651758)));
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
Log.d("picasso", "onBitmapFailed");
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
};