2016-11-21 7 views
0

질문이 있습니다. 내 응용 프로그램에 이미있는 코드이며 다음과 같이 작동합니다. 사진>자르기>업로드입니다. 사진을 자르고 싶지 않습니다. 어떻게해야합니까? dispatchCropImageIntent 메소드를 그냥 삭제 하시겠습니까?Android 앱 자르기 사진

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    Log.d(this.getClass().getSimpleName(), "onActivityResult"); 
    if (resultCode == RESULT_OK) { 
     if (requestCode == REQUEST_IMAGE_CAPTURE) { 
      File imageFile = new File(mCurrentPhotoPath); 
      if (imageFile.exists()) { 
       dispatchCropImageIntent(Uri.fromFile(imageFile)); 
      } 
     } else if (requestCode == REQUEST_IMAGE_FROM_GALLERY_SELECT) { 
      dispatchCropImageIntent(data.getData()); 
     } else if (requestCode == REQUEST_PICTURE_CROP) { 
      String filePath = Environment.getExternalStorageDirectory() 
        + "/temporary_holder.jpg"; 
      setCurrentBitmap(BitmapFactory.decodeFile(filePath)); 
     } else if(requestCode == CAMERA_ACTIVITY_CODE){ 
      // Get path 
      String path = data.getStringExtra(CustomCamera.OUT_PATH); 

      // Read file 
      byte[] imgData = AppFS.readFileFromPath(path); 
      if (imgData != null) { 
       Bitmap bitmap = BitmapFactory.decodeByteArray(imgData , 0, imgData.length); 
       // TODO: Do something with the image, it should be okay 
       //((ImageView)findViewById(R.id.img)).setImageBitmap(bitmap); 
      } else { 
       Log.e("Main", "Data is null"); 
      } 
     } 
    } 
    else{ 
     onBackPressed(); 
    } 
} 

그리고 : 내가 제대로 이해하면

private void dispatchCropImageIntent(Uri uri) { 
    Intent cropImageIntent = new Intent("com.android.camera.action.CROP"); 
    cropImageIntent.setDataAndType(uri, "image/*"); 
    cropImageIntent.putExtra("crop", "true"); 
    cropImageIntent.putExtra("noFaceDetection", true); 
    cropImageIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); 
    // retrieve data on return 
    cropImageIntent.putExtra("return-data", true); 
    File f = new File(Environment.getExternalStorageDirectory(), 
      "/temporary_holder.jpg"); 
    try { 
     f.createNewFile(); 
    } catch (IOException ex) { 
     Log.e("io", ex.getMessage()); 
    } 

    uri = Uri.fromFile(f); 
    cropImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); 
    startActivityForResult(cropImageIntent, REQUEST_PICTURE_CROP); 
} 
+0

dispatchCropImageIntent() 메소드를 삭제하고 나중에 사용할 수 있도록 해당 이미지 경로를 가져 오기 만하면됩니다. – Vadivel

답변

0

, 당신은 당신의 응용 프로그램은 다음과 같은 작업을 만들고 싶어 : 은> 업로드 사진을 걸립니다. 따라서 dispatchCropImageIntent()으로 바꿔야합니다. setCurrentBitmap() 또는 업로드 메쉬.