在android中浮雕图像形状(使用浮雕maskfilter)

在android中浮雕图像形状(使用浮雕maskfilter),android,canvas,drawing,Android,Canvas,Drawing,我想获得一个基于路径对象创建的浮雕位图。问题是浮雕效果仅适用于直尺 我想得到这样的最终结果: 路径对象的创建如下所示 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(); 然后从该路径对象创建位图,如下所示。与压花过滤器

我想获得一个基于路径对象创建的浮雕位图。问题是浮雕效果仅适用于直尺

我想得到这样的最终结果:

路径对象的创建如下所示

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);

不幸的是,
浮雕maskfilter
仅适用于
笔划
填充和笔划
绘制。我无法找到任何关于这方面的文档,但根据我的实验,这些是我能让它工作的唯一案例。

感谢您的回复。因为这个我被困了好几个月。我在实现中使用了FILL_和_STROKE。你的意思是因为我使用了PorterDuff并覆盖了一个图像,所以这不起作用。我怎样才能使这项工作成为可能?