How to make the image angle programmatic

I use text view. I have one image as a background. I want this corner of the image to be rounded. Is there any software solution? Anyone who has any ideas.

+2
source share
1 answer

Convert the image to a bitmap, and then convert it to a rounded bitmap. Finally, apply this bitmap to the background text. The following code is for converting a bitmap into a rounded bitmap.

public static Bitmap getRoundedCornerBitmap(Bitmap bitmap,int roundPixelSize) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = roundPixelSize; paint.setAntiAlias(true); canvas.drawRoundRect(rectF,roundPx,roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; } 
+5
source

Source: https://habr.com/ru/post/1433302/


All Articles