• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Embossing an image shape in android (using EmbossMaskFilter)

patikiri

Lurker
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. http://en.fotolia.com/id/1066946

How can I improve the following code.

Path Object is created as follows

Path mPath=newPath();

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 =newEmbossMaskFilter(newfloat[]{1,1,1},0.4f,6,3.5f);Canvas gfx =newCanvas(piecePicture);


Paint whitePaint =newPaint(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 =newPaint();
paint.setXfermode(newPorterDuffXfermode(android.graphics.PorterDuff.Mode.SRC_IN));
paint.setMaskFilter(mEmboss);// draw the image on path viewBgrnd is the bitmap
gfx.drawBitmap(viewBgrnd,10,10, paint);
Thanks
 
Back
Top Bottom