1

I am working on Android application in which I want to pass image from gallery. Previously my code take image from drawable and send it to cropping class. Now I want to use my gallery pic which I have selected instead of R.id.cropImg.

My code for gallery image with URI is also given below:

// for image gallery

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
// OnActivity 
if (requestCode == SELECT_PICTURE) {
   final Uri selectedImageUri = data.getData();
   //showLoadingDialog();
   if (Build.VERSION.SDK_INT < 19) {
       selectedImagePath = getPath(selectedImageUri);
       int   index=1;
       mIntent.putExtra("index", index);
       startActivityForResult(mIntent, requestCode);
   }
}
// now I want to give the location of my image in place
// of R.id.cropImg

setContentView(R.layout.fragment_cropimage);
final CropImageView mCropImage = (CropImageView)findViewById(R.id.cropImg);
mCropImage.setDrawable(getResources().getDrawable(R.drawable.precrop),300,300);

// Before galley it was taking img from drawable for
// cropping, now I want from gallery.
hardartcore
  • 16,886
  • 12
  • 75
  • 101
Usman Khan
  • 3,739
  • 6
  • 41
  • 89
  • `CropImageView` I think extends `ImageView`, if so, you can just decode the image from the `Uri`. [See this for help](http://stackoverflow.com/a/10474167/2065663) – Saif Hamed Dec 20 '14 at 21:17
  • Check if 'CropImageView' takes 'Bitmap' as param and crop it. Btw please, take some more time how to properly format your code while posting questions here. – hardartcore Mar 13 '18 at 17:03

0 Answers0