بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
برش تصویر و ذخیره و آپلود تصویر جدید
سلام هرچی گشتم چنین چیزی پیدا نکردم یا اینکه نا مفهوم بود من میخوام کاربر وقتی عکس از گالری انتخاب کرد اونو حدااکثر تا سایز 200 برش بده بعد این عکس ذخیره بشه اینم بگم جایگزین عکس قبلی نشه و ادرس عکس جدید رو بفرسه واسه اپلود کدی که من نوشتم عکسو برش میده و جایگیزین عکس قبلی میکنه بعد میفرسه واسه اپلود اینم کد من...مشکل کجاس؟
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_IMAGE) {
picUri = data.getData();
data.getData();
selectedImagePath = getPath(picUri);
performCrop();
selectedImagePath = getPath(picUri);
}
else if(requestCode == PIC_CROP){
data.getExtras();
findViewById(R.id.imgProfile);
//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);
}
selectedImagePath = getPath(picUri);
}
}
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", 200);
cropIntent.putExtra("outputY", 200);
//cropIntent.putExtra("scale", true);
//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();
}
}
@SuppressWarnings("deprecation")
public String getPath(Uri uri)
{
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String picturePath=cursor.getString(column_index);
ImageView imageView = (ImageView) findViewById(R.id.imgProfile); //نمایش عکس انتخاب شده در برنامه
imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
pathToOurFile = picturePath; // قرار دادن مسیر عکس
btnUpload = (Button) findViewById(R.id.btnUp);
btnUpload.setVisibility(View.VISIBLE);
//Toast.makeText(profile.this,picturePath,Toast.LENGTH_LONG).show();
return cursor.getString(column_index);
}
0
0

کسی نیس کمکم کنه؟ (10 سال پیش)
0
0

. (10 سال پیش)
0
0

کسی بلد نیس؟؟؟؟ (10 سال پیش)
+1
0

و دوباره هیچکس بلد نیس جواب سوال منو بده (10 سال پیش)
+1
0

یعنی خداوکیل هیچکس بلد نیس؟؟؟؟ (10 سال پیش)
+1
0

up up up up up up up up up ! (10 سال پیش)
0
0

سدوال این دوستمون بی جواب مونده اساتید! (10 سال پیش)
0
0

سئوال (10 سال پیش)
برای این سوال 2 پاسخ وجود دارد.

پاسخ به سوال
سامان پاپی
10 سال پیش
0
0
دوست فعالیت شما در پست بالا به صورت جدی و عمدا اسم گونه بوده
در جواب سوال شما و دوستمون اقا میثم کد بالا رو نمیدونم و لینکی که به شما میدهم کامل و استاندارد و بسیار مفید هست . استفاده کنید و حتما فیید بکتون رو همراه عکس قرار بدین تا برنامه نویس های اینده هم بتوانند استفاده کنند . موفق باشید

پاسخ به سوال
omidronaldoo
10 سال پیش
0
0
برای crop کردن عکس میتونی از کتابخانه cropped در تاپیک بانک کتابخانه استفاده کنی.
اینم لینک کتابخانه لینک
(10 سال پیش)
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .