Skip to content

Commit b760474

Browse files
committed
Modified getRoundedEdgeBitmap() to allow for no border
1 parent a6eb47a commit b760474

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,13 @@ public static Bitmap getCircularBitmap(final Bitmap bitmap) {
597597
return output;
598598
}
599599

600-
public static Bitmap getRoundedEdgeBitmap(final Bitmap bitmap, int radius) {
600+
/**
601+
* Returns the passed bitmap with rounded corners
602+
* @param bitmap - the bitmap to modify
603+
* @param radius - the radius of the corners
604+
* @param borderColor - the border to apply (use Color.TRANSPARENT for none)
605+
*/
606+
public static Bitmap getRoundedEdgeBitmap(final Bitmap bitmap, int radius, int borderColor) {
601607
if (bitmap == null) {
602608
return null;
603609
}
@@ -616,10 +622,12 @@ public static Bitmap getRoundedEdgeBitmap(final Bitmap bitmap, int radius) {
616622
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
617623
canvas.drawBitmap(bitmap, rect, rect, paint);
618624

619-
paint.setStyle(Paint.Style.STROKE);
620-
paint.setStrokeWidth(1f);
621-
paint.setColor(Color.DKGRAY);
622-
canvas.drawRoundRect(rectF, radius, radius, paint);
625+
if (borderColor != Color.TRANSPARENT) {
626+
paint.setStyle(Paint.Style.STROKE);
627+
paint.setStrokeWidth(1f);
628+
paint.setColor(borderColor);
629+
canvas.drawRoundRect(rectF, radius, radius, paint);
630+
}
623631

624632
return output;
625633
}

0 commit comments

Comments
 (0)