Android BitmapShader作为绘制路径的源

Android BitmapShader作为绘制路径的源,android,bitmap,android-canvas,Android,Bitmap,Android Canvas,是否可以使用非openGL实现图形中显示的效果。基本上,笔划宽度在整个路径中与源位图相同。在您想知道为什么之前,Paint.setMaskFilter相当慢。我宁愿在位图中预渲染模糊,然后用它来画画 价值代码: paint = new Paint(); paint.setAntiAlias(true); paint.setDither(true); paint.setStrokeWidth(40f); paint.setStyle(Paint.Style.STROKE); paint.setPa

是否可以使用非openGL实现图形中显示的效果。基本上,笔划宽度在整个路径中与源位图相同。在您想知道为什么之前,Paint.setMaskFilter相当慢。我宁愿在位图中预渲染模糊,然后用它来画画

价值代码:

paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setStrokeWidth(40f);
paint.setStyle(Paint.Style.STROKE);
paint.setPathEffect(new CornerPathEffect(8f));
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.shader_source);
BitmapShader shader = new BitmapShader(bm, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
paint.setShader(shader);