使用位图作为绘制对象的android绘制 [英] android paint using bitmaps as a paint object
问题描述
我正在构建绘图应用程序,并且想创建自定义画笔.我假设有一种方法可以设置您的android.graphics.Paint
对象,使其沿路径使用位图而不是颜色,但这似乎并非如此.我想我可以保存路径并为其绘制位图,但这似乎过多..在我开始尝试提出自定义解决方案之前,我想知道是否有人已经解决了这个问题.这个想法是说我有一个星形"图标,ID的意思是能够根据笔划宽度到用户绘制的路径绘制一行星形.
I am building a drawing app and would like to create custom brushes. I assumed there was a way to set your android.graphics.Paint
object to use a bitmap along the path instead of a color, but this doesn't seem to be the case.. I suppose i could just save the path and draw bitmaps to it, but that seems excessive.. before i start trying to come up with a custom solution i was wondering if anyone has already tackled this. The idea is lets say i had a 'star' icon, id like to be able to draw a line of stars based on stroke width to the path the user has drawn..
伪代码:
drawPath = new Path();
drawPaint = new Paint();
//drawPaint.setColor(paintColor);
drawPaint.setBitmap(bitmap); /// <-- wouldn't that be sweet
推荐答案
Nevermind ..我找到了..我知道我可以做到..
Nevermind.. i found it.. i knew i could do this..
drawPaint.setShader(new BitmapShader(bm, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT));
这篇关于使用位图作为绘制对象的android绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!