Android Utililty Methods Bitmap Crop

List of utility methods to do Bitmap Crop

Description

The list of methods to do Bitmap Crop are organized into topic(s).

Method

BitmapresizeDownToPixels(Bitmap bitmap, int targetPixels, boolean recycle)
resize Down To Pixels
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float scale = (float) Math.sqrt((double) targetPixels
        / (width * height));
if (scale >= 1.0f)
    return bitmap;
return resizeBitmapByScale(bitmap, scale, recycle);
IntentcropImage(Context context, Uri imageuri, Uri tempUri)
crop Image
try {
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(tempUri, "image/*");
    intent.putExtra("crop", "true");
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("outputX", 100);
    intent.putExtra("outputY", 100);
...
BitmapgetCroppedBitmap(Bitmap bitmap)
get Cropped Bitmap
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
        bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(),
        bitmap.getHeight());
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
...