1

I have a demo which first takes an image from camera than ask user to crop the image.Cropping screen have a rectangle box in middle which on touch of the border of the 4 faces displays 4 arrows at midpoint of the faces to change the size of the box as user wants.As it is the inbuilt mechanism provided by using intent com.android.camera.action.CROP.

I want to make the same thing but for circular window.Which crops circular images.

Do any one have previous experience with this kind of cropping functionality. Please help me out.

kaushal trivedi
  • 3,405
  • 3
  • 29
  • 47

1 Answers1

1

Have a look at this function... Is this what you require??

public Bitmap getCroppedBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
        bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);

final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
// canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
        bitmap.getWidth() / 2, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
//Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false);
//return _bmp;
return output;
}

Check this link.. crop image

If you are using Intents.. try using this

   intent.setType("image/*");
   intent.putExtra("crop", "true");
   intent.putExtra("scale", scale);
   intent.putExtra("return-data", return_data);
   intent.putExtra("circleCrop", true);
Community
  • 1
  • 1
G_S
  • 7,068
  • 2
  • 21
  • 51