想要剪切画布圈的背景图片
Posted
技术标签:
【中文标题】想要剪切画布圈的背景图片【英文标题】:Want to Cut background image of canvas circle 【发布时间】:2014-01-03 13:33:56 【问题描述】:想要剪切画布圆圈的背景图片
canvas.drawBitmap(background_image, 0, 0, null);
FaceDetector.Face face = faces[0];
tmp_paint.setColor(Color.RED);
`face.getMidPoint(tmp_point);
canvas.drawCircle(tmp_point.x, tmp_point.y, face.eyesDistance(), tmp_paint);
【问题讨论】:
【参考方案1】:您可以使用以下功能:
public Bitmap getRoundedShape(Bitmap scaleBitmapImage)
int targetWidth = 125;
int targetHeight = 125;
Bitmap targetBitmap = Bitmap.createBitmap(targetWidth,
targetHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.addCircle(
((float) targetWidth - 1) / 2,
((float) targetHeight - 1) / 2,
(Math.min(((float) targetWidth), ((float) targetHeight)) / 2),
Path.Direction.CCW);
canvas.clipPath(path);
Bitmap sourceBitmap = scaleBitmapImage;
canvas.drawBitmap(
sourceBitmap,
new Rect(0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight()),
new Rect(0, 0, targetWidth, targetHeight),
p);
return targetBitmap;
更多详情请查看:http://www.androiddevelopersolutions.com/2012/09/crop-image-in-circular-shape-in-android.html
【讨论】:
new Rect(0, 0, sourceBitmap.getWidth(), sourceBitmap .getHeight()), new Rect(0, 0, targetWidth, targetHeight), p)中的“p”是什么;这是一条路吗?????? p 是绘画的对象以上是关于想要剪切画布圈的背景图片的主要内容,如果未能解决你的问题,请参考以下文章