我想获得一个基于Path对象创建的浮雕位图。问题是浮雕效果仅适用于直边。
我想得到这样的最终结果:
路径对象创建如下
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();
然后如下从该路径对象创建位图。带浮雕滤镜。
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);
答案 0 :(得分:1)
不幸的是,EmbossMaskFilter
仅适用于STROKE
和FILL_AND_STROKE
涂料。我无法指出任何有关此问题的文档,但根据我的实验,这些是我可以让它工作的唯一情况。