简体   繁体   English

在Android上浮雕表示图像的路径

[英]Emboss a Path representing image on android

I am trying to draw an image on a Path (which is a closed irregular shape). 我正在尝试在路径(封闭的不规则形状)上绘制图像。 I have used PorterDuffXfermode . 我用过PorterDuffXfermode My objective is to use EmbossMaskFilter and create a emboss effect on the final image shape output. 我的目标是使用EmbossMaskFilter并在最终的图像形状输出上创建浮雕效果。 See the code below. 请参见下面的代码。 However, even I draw the piecePicture it looks flat. 但是,即使我将piecePicturePicture绘制为看起来也很平坦。

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

Thanks 谢谢

After drawing the image using PorterDuffXfermode. 使用PorterDuffXfermode绘制图像后。 piecePicture has to be redrawn on a canvas using a Paint Object with emboss filter. piecePicture必须使用带有浮雕滤镜的Paint Object在画布上重绘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM