Closed NicodeLee closed 9 years ago
Sorry...SimpleCropView does not support circle crop. You can try this code with SimpleCropView.
CropImageView cropImageView = (CropImageView)findViewById(R.id.cropImageView); // Set image cropImageView.setImageBitmap(image); // Get square image cropImageView.setCropMode(CropImageView.CropMode.RATIO_1_1); Bitmap squareImage = cropImageView.getCroppedBitmap(); // Get circle image from square image Bitmap circleImage = ImageUtils.getCircleBitmap(squareImage);
public class ImageUtils { public static Bitmap getCircleBitmap(Bitmap square) { if (square == null) return null; Bitmap output = Bitmap.createBitmap(square.getWidth(), square.getHeight(), Bitmap.Config.ARGB_8888); final Rect rect = new Rect(0, 0, square.getWidth(), square.getHeight()); Canvas canvas = new Canvas(output); int halfWidth = square.getWidth() / 2; int halfHeight = square.getHeight() / 2; final Paint paint = new Paint(); paint.setAntiAlias(true); paint.setFilterBitmap(true); canvas.drawCircle(halfWidth, halfHeight, Math.min(halfWidth, halfHeight), paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(square, rect, rect, paint); return output; } }
Version 1.0.8 has been released. SimpleCropView now supports circle crop.
See it,Thanks for your work.
Sorry...SimpleCropView does not support circle crop. You can try this code with SimpleCropView.