private Bitmap clippedRotatedOval(Bitmap bitmap) {
Bitmap bmp;
float width = bitmap.getWidth();
float height = bitmap.getHeight();
bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
Canvas canvas = new Canvas(bmp);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(shader);
Path oval = new Path();
Matrix matrix = new Matrix();
Region region = new Region();
RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);
oval.addOval(ovalRect, Path.Direction.CW);
matrix.postRotate(ROTATION, width / 2, height / 2);
oval.transform(matrix, oval);
region.setPath(oval, new Region((int) width / 2, 0, (int) width, (int) height));
canvas.drawPath(region.getBoundaryPath(), paint);
return bmp;
}
ShapedImageView.java 文件源码
java
阅读 36
收藏 0
点赞 0
评论 0
项目:PresenterLite
作者:
评论列表
文章目录