Android: Free Cropping of Image

Android: Free Cropping of Image

  • Load image from gallery or camera on View (Using Canvas Draw image)

     public class SomeView extends View implements OnTouchListener {
    private Paint paint;
    public static List<Point> points;
    int DIST = 2;
    boolean flgPathDraw = true;

    Point mfirstpoint = null;
    boolean bfirstpoint = false;

    Point mlastpoint = null;

    Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
    R.drawable.gallery_12);
    Context mContext;

    public SomeView(Context c) {
    super(c);

    mContext = c;
    setFocusable(true);
    setFocusableInTouchMode(true);

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.STROKE);
    paint.setPathEffect(new DashPathEffect(new float[] { 10, 20 }, 0));
    paint.setStrokeWidth(5);
    paint.setColor(Color.WHITE);

    this.setOnTouchListener(this);
    points = new ArrayList<Point>();

    bfirstpoint = false;
    }

    public SomeView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;
    setFocusable(true);
    setFocusableInTouchMode(true);

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(2);
    paint.setColor(Color.WHITE);

    this.setOnTouchListener(this);
    points = new ArrayList<Point>();
    bfirstpoint = false;

    }

    public void onDraw(Canvas canvas) {
    canvas.drawBitmap(bitmap, 0, 0, null);

    Path path = new Path();
    boolean first = true;

    for (int i = 0; i < points.size(); i += 2) {
    Point point = points.get(i);
    if (first) {
    first = false;
    path.moveTo(point.x, point.y);
    } else if (i < points.size() - 1) {
    Point next = points.get(i + 1);
    path.quadTo(point.x, point.y, next.x, next.y);
    } else {
    mlastpoint = points.get(i);
    path.lineTo(point.x, point.y);
    }
    }
    canvas.drawPath(path, paint);
    }

    public boolean onTouch(View view, MotionEvent event) {
    // if(event.getAction() != MotionEvent.ACTION_DOWN)
    // return super.onTouchEvent(event);

    Point point = new Point();
    point.x = (int) event.getX();
    point.y = (int) event.getY();

    if (flgPathDraw) {

    if (bfirstpoint) {

    if (comparepoint(mfirstpoint, point)) {
    // points.add(point);
    points.add(mfirstpoint);
    flgPathDraw = false;
    showcropdialog();
    } else {
    points.add(point);
    }
    } else {
    points.add(point);
    }

    if (!(bfirstpoint)) {

    mfirstpoint = point;
    bfirstpoint = true;
    }
    }

    invalidate();
    Log.e("Hi ==>", "Size: " + point.x + " " + point.y);

    if (event.getAction() == MotionEvent.ACTION_UP) {
    Log.d("Action up*******~~~~~~~>>>>", "called");
    mlastpoint = point;
    if (flgPathDraw) {
    if (points.size() > 12) {
    if (!comparepoint(mfirstpoint, mlastpoint)) {
    flgPathDraw = false;
    points.add(mfirstpoint);
    showcropdialog();
    }
    }
    }
    }

    return true;
    }

    private boolean comparepoint(Point first, Point current) {
    int left_range_x = (int) (current.x - 3);
    int left_range_y = (int) (current.y - 3);

    int right_range_x = (int) (current.x + 3);
    int right_range_y = (int) (current.y + 3);

    if ((left_range_x < first.x && first.x < right_range_x)
    && (left_range_y < first.y && first.y < right_range_y)) {
    if (points.size() < 10) {
    return false;
    } else {
    return true;
    }
    } else {
    return false;
    }

    }

    public void fillinPartofPath() {
    Point point = new Point();
    point.x = points.get(0).x;
    point.y = points.get(0).y;

    points.add(point);
    invalidate();
    }

    public void resetView() {
    points.clear();
    paint.setColor(Color.WHITE);
    paint.setStyle(Style.STROKE);
    flgPathDraw = true;
    invalidate();
    }

    private void showcropdialog() {
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
    Intent intent;
    switch (which) {
    case DialogInterface.BUTTON_POSITIVE:
    // Yes button clicked
    // bfirstpoint = false;

    intent = new Intent(mContext, CropActivity.class);
    intent.putExtra("crop", true);
    mContext.startActivity(intent);
    break;

    case DialogInterface.BUTTON_NEGATIVE:
    // No button clicked

    intent = new Intent(mContext, CropActivity.class);
    intent.putExtra("crop", false);
    mContext.startActivity(intent);

    bfirstpoint = false;
    // resetView();

    break;
    }
    }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage("Do you Want to save Crop or Non-crop image?")
    .setPositiveButton("Crop", dialogClickListener)
    .setNegativeButton("Non-crop", dialogClickListener).show()
    .setCancelable(false);
    }
    }

    class Point {

    public float dy;
    public float dx;
    float x, y;

    @Override
    public String toString() {
    return x + ", " + y;
    }
    }
  • MainActivity Which call Someview to draw/load image

    public class MainActivity_ extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    }

    @Override
    protected void onResume() {
    super.onResume();
    setContentView(new SomeView(MainActivity_.this));
    }

    }
  • CropActivity : which load crop image on bitmap.

     public class CropActivity extends Activity {

    ImageView compositeImageView;
    boolean crop;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cropview);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
    crop = extras.getBoolean("crop");
    }
    int widthOfscreen = 0;
    int heightOfScreen = 0;

    DisplayMetrics dm = new DisplayMetrics();
    try {
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    } catch (Exception ex) {
    }
    widthOfscreen = dm.widthPixels;
    heightOfScreen = dm.heightPixels;

    compositeImageView = (ImageView) findViewById(R.id.our_imageview);

    Bitmap bitmap2 = BitmapFactory.decodeResource(getResources(),
    R.drawable.gallery_12);

    Bitmap resultingImage = Bitmap.createBitmap(widthOfscreen,
    heightOfScreen, bitmap2.getConfig());

    Canvas canvas = new Canvas(resultingImage);
    Paint paint = new Paint();
    paint.setAntiAlias(true);

    Path path = new Path();
    for (int i = 0; i < SomeView.points.size(); i++) {
    path.lineTo(SomeView.points.get(i).x, SomeView.points.get(i).y);
    }
    canvas.drawPath(path, paint);
    if (crop) {
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));

    } else {
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT));
    }
    canvas.drawBitmap(bitmap2, 0, 0, paint);
    compositeImageView.setImageBitmap(resultingImage);
    }
    }

How to implement freehand image cropping in android?

In general, your code looks OK, but I have a few comments:

  • Unable to set bitmap in full screen using canvas
  • If i set bitmap in full screen in canvas than image is stretching

    The portion of the image that you are selecting needs to be placed in a smaller bitmap so the layout XML can position it as you like. You are creating a bitmap that is full screen. See the following demo for details.

  • How to set transparent background to cropped bitmap

    I am unclear about what the issue is.

  • Unable to add border to cropped image

  • The result of image Cropping is not as expected

    See below.

Here is a small demo app using your code. You didn't provide an MCVE, so I threw the following together for demonstration purposes. Other than getting the app to function I think that the only change is to draw the border in MainActivity.java. The border width starts at the cut-out path that the user draws and reaches inward to the cut-out. If you want to actually frame the cutout without losing any pixels, then you will need to expand the path to accommodate the frame which I arbitrarily set to 20 pixels.

I also had to create the layouts used, so you may want to look at those. They are posted below.

Here is the demo video with the code to follow:

Sample Image

MainActivity.java

public class MainActivity extends AppCompatActivity {
private Bitmap mBitmap;
private SomeView mSomeView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.dog);
mSomeView = new SomeView(this, mBitmap);
LinearLayout layout = findViewById(R.id.layout);
LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layout.addView(mSomeView, lp);
}

public void cropImage() {
setContentView(R.layout.activity_picture_preview);
ImageView imageView = findViewById(R.id.image);

Bitmap fullScreenBitmap =
Bitmap.createBitmap(mSomeView.getWidth(), mSomeView.getHeight(), mBitmap.getConfig());

Canvas canvas = new Canvas(fullScreenBitmap);

Path path = new Path();
List<Point> points = mSomeView.getPoints();
for (int i = 0; i < points.size(); i++) {
path.lineTo(points.get(i).x, points.get(i).y);
}

// Cut out the selected portion of the image...
Paint paint = new Paint();
canvas.drawPath(path, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(mBitmap, 0, 0, paint);

// Frame the cut out portion...
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(10f);
canvas.drawPath(path, paint);

// Create a bitmap with just the cropped area.
Region region = new Region();
Region clip = new Region(0, 0, fullScreenBitmap.getWidth(), fullScreenBitmap.getHeight());
region.setPath(path, clip);
Rect bounds = region.getBounds();
Bitmap croppedBitmap =
Bitmap.createBitmap(fullScreenBitmap, bounds.left, bounds.top,
bounds.width(), bounds.height());

imageView.setImageBitmap(croppedBitmap);
}
}

SomeView.java
I don't think there were any substantive changes to this class.

public class SomeView extends View implements View.OnTouchListener {  
private Paint paint;
private List<Point> points;

int DIST = 2;
boolean flgPathDraw = true;

Point mfirstpoint = null;
boolean bfirstpoint = false;

Point mlastpoint = null;

Bitmap bitmap;

Context mContext;

public SomeView(Context c, Bitmap bitmap) {
super(c);

mContext = c;
this.bitmap = bitmap;

setFocusable(true);
setFocusableInTouchMode(true);

paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
paint.setStrokeWidth(5);
paint.setColor(Color.RED);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);

this.setOnTouchListener(this);
points = new ArrayList<Point>();

bfirstpoint = false;
}

public SomeView(Context context, AttributeSet attrs) {
super(context, attrs);

mContext = context;
setFocusable(true);
setFocusableInTouchMode(true);

paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(5);
paint.setColor(Color.RED);

points = new ArrayList<Point>();
bfirstpoint = false;

this.setOnTouchListener(this);
}

public void onDraw(Canvas canvas) {

/*Rect dest = new Rect(0, 0, getWidth(), getHeight());

paint.setFilterBitmap(true); canvas.drawBitmap(bitmap, null, dest, paint);*/
canvas.drawBitmap(bitmap, 0, 0, null);

Path path = new Path();
boolean first = true;

for (int i = 0; i < points.size(); i += 2) {
Point point = points.get(i);
if (first) {
first = false;
path.moveTo(point.x, point.y);
} else if (i < points.size() - 1) {
Point next = points.get(i + 1);
path.quadTo(point.x, point.y, next.x, next.y);
} else {
mlastpoint = points.get(i);
path.lineTo(point.x, point.y);
}
}
canvas.drawPath(path, paint);
}

public boolean onTouch(View view, MotionEvent event) {
// if(event.getAction() != MotionEvent.ACTION_DOWN)
// return super.onTouchEvent(event);
Point point = new Point();
point.x = (int) event.getX();
point.y = (int) event.getY();

if (flgPathDraw) {

if (bfirstpoint) {

if (comparepoint(mfirstpoint, point)) {
// points.add(point);
points.add(mfirstpoint);
flgPathDraw = false;
showcropdialog();
} else {
points.add(point);
}
} else {
points.add(point);
}

if (!(bfirstpoint)) {

mfirstpoint = point;
bfirstpoint = true;
}
}

invalidate();
Log.e("Hi ==>", "Size: " + point.x + " " + point.y);

if (event.getAction() == MotionEvent.ACTION_UP) {
Log.d("Action up*****~~>>>>", "called");
mlastpoint = point;
if (flgPathDraw) {
if (points.size() > 12) {
if (!comparepoint(mfirstpoint, mlastpoint)) {
flgPathDraw = false;
points.add(mfirstpoint);
showcropdialog();
}
}
}
}

return true;
}

private boolean comparepoint(Point first, Point current) {
int left_range_x = (int) (current.x - 3);
int left_range_y = (int) (current.y - 3);

int right_range_x = (int) (current.x + 3);
int right_range_y = (int) (current.y + 3);

if ((left_range_x < first.x && first.x < right_range_x)
&& (left_range_y < first.y && first.y < right_range_y)) {
if (points.size() < 10) {
return false;
} else {
return true;
}
} else {
return false;
}

}

public void fillinPartofPath() {
Point point = new Point();
point.x = points.get(0).x;
point.y = points.get(0).y;

points.add(point);
invalidate();
}

public void resetView() {
points.clear();
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);

paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(5);
paint.setColor(Color.RED);

points = new ArrayList<Point>();
bfirstpoint = false;

flgPathDraw = true;
invalidate();
}

private void showcropdialog() {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent;
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
((MainActivity) mContext).cropImage();
break;

case DialogInterface.BUTTON_NEGATIVE:
/*// No button clicked

intent = new Intent(mContext, DisplayCropActivity.class); intent.putExtra("crop", false); mContext.startActivity(intent);
bfirstpoint = false;*/ resetView();

break;
}
}
};

AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setMessage("Do you Want to save Crop or Non-crop image?")
.setPositiveButton("Crop", dialogClickListener)
.setNegativeButton("Non-crop", dialogClickListener).show()
.setCancelable(false);
}

public List<Point> getPoints() {
return points;
}
}

activity_main.xml

<LinearLayout 
android:id="@+id/layout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"/>

activity_picture_preview.xml

<android.support.constraint.ConstraintLayout x
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">

<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@drawable/dog" />
</android.support.constraint.ConstraintLayout>

If you want to create a cropped bitmap with a 100px border, use the following code in cropImage():

    // Create a bitmap with just the cropped area.
Region region = new Region();
Region clip = new Region(0, 0, fullScreenBitmap.getWidth(), fullScreenBitmap.getHeight());
region.setPath(path, clip);
Rect sourceBounds = region.getBounds();
Rect destBounds =
new Rect(CROPPED_MARGIN, CROPPED_MARGIN, sourceBounds.width() + CROPPED_MARGIN,
sourceBounds.height() + CROPPED_MARGIN);
Bitmap croppedBitmap =
Bitmap.createBitmap(sourceBounds.width() + CROPPED_MARGIN * 2,
sourceBounds.height() + CROPPED_MARGIN * 2, mBitmap.getConfig());
canvas.setBitmap(croppedBitmap);
canvas.drawBitmap(fullScreenBitmap, sourceBounds, destBounds, null);

imageView.setImageBitmap(croppedBitmap);

// Add as member variable.
private static final int CROPPED_MARGIN = 100;

Cropping image in irregular shape in android not working proper

I have solved and completely set this cropping and saving of image using Android: Free Croping of Image with some modifications for choosing images and fitting images in screen by my self and my code is modifications are as under

public class SomeView extends View implements OnTouchListener {
private Paint paint;
public static List<Point> points;
int DIST = 2;
boolean flgPathDraw = true;
public Uri orignalUri;
float origianlheight=0.0f,originalwidth=0.0f,heightratio=0.0f,widthratio=0.0f;
public static int REQUEST_CODE=2;
Point mfirstpoint = null;
boolean bfirstpoint = false;

Point mlastpoint = null;
boolean cropflag=false;

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.bg_crop);
Context mContext;

public void setBitmap(Bitmap bmp,Uri uri){
orignalUri=uri;
points = new ArrayList<Point>();
setFocusable(true);
setFocusableInTouchMode(true);

DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;
origianlheight=bmp.getHeight();
originalwidth=bmp.getWidth();
//if(origianlheight>originalwidth){
heightratio=height/origianlheight;
// }else{
widthratio=width/originalwidth;
// }
bitmap=bmp;
bitmap=Bitmap.createScaledBitmap(bmp, (int)(bmp.getWidth()*widthratio),(int)(bmp.getHeight()*heightratio), true);

// bitmap=bmp;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setPathEffect(new DashPathEffect(new float[] { 10, 20 }, 0));
paint.setStrokeWidth(5);
paint.setColor(Color.WHITE);

flgPathDraw = true;
this.setOnTouchListener(this);
points = new ArrayList<Point>();
bfirstpoint = false;
cropflag=false;

}
public void clear(){
setFocusable(true);
setFocusableInTouchMode(true);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setPathEffect(new DashPathEffect(new float[] { 10, 20 }, 0));
paint.setStrokeWidth(5);
paint.setColor(Color.WHITE);
this.setOnTouchListener(this);
points = new ArrayList<Point>();

bfirstpoint = false;
flgPathDraw = true;
cropflag=false;
invalidate();
}

public SomeView(Context c) {
super(c);

mContext = c;
setFocusable(true);
setFocusableInTouchMode(true);

DisplayMetrics metrics = c.getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;
origianlheight=bitmap.getHeight();
originalwidth=bitmap.getWidth();
//if(origianlheight>originalwidth){
heightratio=height/origianlheight;
// }else{
widthratio=width/originalwidth;
// }
bitmap=Bitmap.createScaledBitmap(bitmap, (int)(originalwidth*widthratio),(int)(origianlheight*heightratio), true);

paint = new Paint(Paint.ANTI_ALIAS_FLAG);

paint.setStyle(Paint.Style.STROKE);
paint.setPathEffect(new DashPathEffect(new float[] { 10, 20 }, 0));
paint.setStrokeWidth(5);
paint.setColor(Color.WHITE);

this.setOnTouchListener(this);
points = new ArrayList<Point>();

bfirstpoint = false;
flgPathDraw = true;
cropflag=false;
}

public SomeView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
setFocusable(true);
setFocusableInTouchMode(true);

DisplayMetrics metrics = context.getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;
origianlheight=bitmap.getHeight();
originalwidth=bitmap.getWidth();
//if(origianlheight>originalwidth){
heightratio=height/origianlheight;
// }else{
widthratio=width/originalwidth;
// }
bitmap=Bitmap.createScaledBitmap(bitmap, (int)(originalwidth*widthratio),(int)(origianlheight*heightratio), true);

paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setPathEffect(new DashPathEffect(new float[] { 10, 20 }, 0));
paint.setStrokeWidth(5);
paint.setColor(Color.WHITE);
this.setOnTouchListener(this);
points = new ArrayList<Point>();
bfirstpoint = false;
flgPathDraw = true;
cropflag=false;

}

public void onDraw(Canvas canvas) {
canvas.drawBitmap(bitmap, 0, 0,paint);

Path path = new Path();
boolean first = true;

for (int i = 0; i < points.size(); i += 2) {
Point point = points.get(i);
if (first) {
first = false;
path.moveTo(point.x, point.y);
} else if (i < points.size() - 1) {
Point next = points.get(i + 1);
path.quadTo(point.x, point.y, next.x, next.y);
} else {
mlastpoint = points.get(i);
path.lineTo(point.x, point.y);
}
}
canvas.drawPath(path, paint);
}
@Override
public boolean onTouch(View view, MotionEvent event) {
// if(event.getAction() != MotionEvent.ACTION_DOWN)
// return super.onTouchEvent(event);

Point point = new Point();
point.x = (int) event.getX();
point.y = (int) event.getY();

if (flgPathDraw) {

if (bfirstpoint) {

if (comparepoint(mfirstpoint, point)) {
// points.add(point);
points.add(mfirstpoint);
flgPathDraw = false;
// showcropdialog();
cropflag=true;
} else {
points.add(point);
}
} else {
points.add(point);
}

if (!(bfirstpoint)) {

mfirstpoint = point;
bfirstpoint = true;
}
}

invalidate();
Log.e("Hi ==>", "Size: " + point.x + " " + point.y);

if (event.getAction() == MotionEvent.ACTION_UP) {
Log.d("Action up*******~~~~~~~>>>>", "called");
mlastpoint = point;
if (flgPathDraw) {
if (points.size() > 12) {
if (!comparepoint(mfirstpoint, mlastpoint)) {
flgPathDraw = false;
points.add(mfirstpoint);
// showcropdialog();
cropflag=true;

}
}
}
}

return true;
}

private boolean comparepoint(Point first, Point current) {
int left_range_x = (int) (current.x - 3);
int left_range_y = (int) (current.y - 3);

int right_range_x = (int) (current.x + 3);
int right_range_y = (int) (current.y + 3);

if ((left_range_x < first.x && first.x < right_range_x)
&& (left_range_y < first.y && first.y < right_range_y)) {
if (points.size() < 10) {
return false;
} else {
return true;
}
} else {
return false;
}

}

public void fillinPartofPath() {
Point point = new Point();
point.x = points.get(0).x;
point.y = points.get(0).y;

points.add(point);
invalidate();
}

public void resetView() {
points.clear();
paint.setColor(Color.WHITE);
paint.setStyle(Style.STROKE);
flgPathDraw = true;
invalidate();
}

/* private void showcropdialog() {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent;
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
// Yes button clicked
// bfirstpoint = false;

intent = new Intent(mContext, CropActivity.class);
intent.putExtra("crop", true);
intent.putExtra("heightratio", heightratio);
intent.putExtra("widthratio", widthratio);
intent.putExtra("URI", orignalUri.toString());
mContext.startActivity(intent);
break;

case DialogInterface.BUTTON_NEGATIVE:
// No button clicked

intent = new Intent(mContext, CropActivity.class);
intent.putExtra("crop", false);
intent.putExtra("heightratio", heightratio);
intent.putExtra("widthratio", widthratio);
}
}
}
}


Related Topics



Leave a reply



Submit