this can only be done with a custom view. I have the same problem. Take a look at Custom ImageView and Paths and crop the bitmap images. I wrote this snippet to cut out the shape of a speech bubble from a given bitmap:
public static Bitmap clipit(Bitmap bitmapimg,int direct) { //1 = direction right //0 = direction left Bitmap output = Bitmap.createBitmap(bitmapimg.getWidth(), bitmapimg.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmapimg.getWidth(), bitmapimg.getHeight()); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); if(direct == 0) { canvas.drawRect(0, 0, bitmapimg.getWidth()-15, bitmapimg.getHeight(), paint); Path path = new Path(); path.moveTo(bitmapimg.getWidth()-15, 10); path.lineTo(bitmapimg.getWidth(), 20); path.lineTo(bitmapimg.getWidth()-15, 30); path.lineTo(bitmapimg.getWidth()-15, 10); canvas.drawPath(path,paint); } if(direct == 1) { canvas.drawRect(15, 0, bitmapimg.getWidth(), bitmapimg.getHeight(), paint); Path path = new Path(); path.moveTo(15, 10); path.lineTo(0, 20); path.lineTo(15, 30); path.lineTo(15, 10); canvas.drawPath(path,paint); } paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmapimg, rect, rect, paint); return output; }
Does this solve your problem?
source share