如何将图像位置从图库传递到Drawable?

时间:2014-12-20 20:33:50

标签: android image image-gallery android-gallery

我正在开发Android应用程序,我想从库中传递图像。以前我的代码从drawable获取图像并将其发送到cropping类。现在我想使用我选择的画廊图片而不是R.id.cropImg。

我的带有URI的图库图片代码如下:

// 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.

0 个答案:

没有答案