بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
برش تصویر
سلام من تمام کارهایی که گفتین واسه برش عکس انجام دادم ولی یه مشکل دارم اول اینکه من یه تابع getpath دارم که ورودی uri داره حالا وقتی عکسو برش دارم دیگه از
Bundle extras = data.getExtras();
استفاده میکنم و درنتیجه از
Uri selectedImageUri = data.getData();
نمیتونم استفاده کنم من سورس کامل کدمو میزارم که بهتر متوجه بشید!خلاصه بگم میخوام عکس که برش دادم ذخیره کنم و ادرسشو بگیرم
و در کلیک باتن
@Override
public void onClick(View arg0) {
Intent intent_gallery = new Intent();
intent_gallery.setType("image/*");
intent_gallery.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent_gallery, SELECT_IMAGE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_IMAGE) {
//performCrop();
picUri = data.getData();
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(picUri);
}
else if(requestCode == PIC_CROP){
//get the returned data
Bundle extras = data.getExtras();
//get the cropped bitmap
Bitmap thePic = extras.getParcelable("data");
//retrieve a reference to the ImageView
ImageView picView = (ImageView)findViewById(R.id.imgProfile);
//display the returned cropped image
picView.setImageBitmap(thePic);
}
}
}
private void performCrop(){
try {
//call the standard crop action intent (the user device may not support it)
Intent cropIntent = new Intent("com.android.camera.action.CROP");
//indicate image type and Uri
cropIntent.setDataAndType(picUri, "image/*");
//set crop properties
cropIntent.putExtra("crop", "true");
//indicate aspect of desired crop
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
//indicate output X and Y
cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);
//retrieve data on return
cropIntent.putExtra("return-data", true);
//save output image in uri
//cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, picUri);
//start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, PIC_CROP);
//respond to users whose devices do not support the crop action
}
catch(ActivityNotFoundException anfe){
//display an error message
String errorMessage = "Whoops - your device doesn't support the crop action!";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
0
0
من سوالام بد میپرسم یا کسی بلد نیس یا کسی جوابم نمیده؟ (11 سال پیش)
+1
0
یه نگاه به این لینک بنداز شاید کمکت کنه (11 سال پیش)
0
0
نظر من چرا بعنوان اسپم شناخته شد و حذف شد؟ (11 سال پیش)
برای این سوال پاسخی وجود ندارد.
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .