I want to get an embossed bitmap created based on a Path object. The problem is that embossed effect only applies for straight edge.
I want to get a final result like this:
Path Object is created as follows
Path mPath= new Path();
mPath.moveTo(100, 100);
mPath.lineTo(200, 100);
mPath.lineTo(150, 150);
mPath.lineTo(200, 200);
mPath.lineTo(100, 200);
mPath.close();
Then a bitmap is created out of this path object as follows. With the embossed filter.
piecePicture = Bitmap.createBitmap(200, 200,Bitmap.Config.ARGB_8888);
MaskFilter mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f);
Canvas gfx = new Canvas(piecePicture);
Paint whitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
whitePaint.setColor(Color.WHITE);
whitePaint.setStyle(Paint.Style.FILL_AND_STROKE);
whitePaint.setStrokeWidth(1);
// shape image has to take
mPath.addRect(10, 10, 195, 195, Direction.CCW);
gfx.drawPath(mPath, whitePaint);
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.SRC_IN));
paint.setMaskFilter(mEmboss);
// draw the image on path viewBgrnd is the bitmap
gfx.drawBitmap(viewBgrnd, 10,10, paint);