CropCircleWithBorderTransformation - border radius incorrect
fprt77 opened this issue · 1 comments
fprt77 commented
TransformationUtils.circleCrop(...)
is working with minimal edge (Math.min(destWidth, destHeight)
), but CropCircleWithBorderTransformation is drawing border radius using maximal edge.
As a result border is not around image when target width and height are different.
fprt77 commented
Fixed transform function should look like this:
@Override
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
@NonNull Bitmap toTransform, int outWidth, int outHeight) {
Bitmap bitmap = TransformationUtils.circleCrop(pool, toTransform, outWidth, outHeight);
setCanvasBitmapDensity(toTransform, bitmap);
Paint paint = new Paint();
paint.setColor(borderColor);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(borderSize);
paint.setAntiAlias(true);
int outMinEdge = Math.min(outWidth, outHeight);
Canvas canvas = new Canvas(bitmap);
canvas.drawCircle(
outMinEdge / 2f,
outMinEdge / 2f,
outMinEdge / 2f - borderSize / 2f,
paint
);
return bitmap;
}
I would create PR myself, but I do not have rights to push, since I am not marked as contributor.