2017-08-01 69 views
0

嗨,基本上我選擇圖像窗體庫或從相機捕獲和裁剪它。如果我裁剪從圖庫中選擇的圖像沒有模糊,但是如果我裁剪捕獲的圖像意味着它變得模糊。裁剪捕獲的圖像是模糊在Android中

要啓動相機,我已經使用

private void cameraIntent() 
    { 
     Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
     startActivityForResult(intent, REQUEST_CAMERA); 

    } 

,並在相機onActivityResult

private void onCaptureImageResult(Intent data) { 
     Bitmap bm = (Bitmap) data.getExtras().get("data"); 
     ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
     bm.compress(Bitmap.CompressFormat.JPEG, 90, bytes); 
     crop(getImageUri(csActivity,bm)); 

    } 

這對作物圖像

private void crop(Uri uri) 
    { 
     final Intent intent = new Intent("com.android.camera.action.CROP"); 
     intent.setData(uri); 
     intent.putExtra("crop", "true"); 
     intent.putExtra("aspectX", 1); 
     intent.putExtra("aspectY", 1); 
     intent.putExtra("outputX", 96); 
     intent.putExtra("outputY", 96); 
     intent.putExtra("noFaceDetection", true); 
     intent.putExtra("return-data", true); 
     startActivityForResult(intent, REQUEST_CROP); 
    } 

,並在作物的結果我已經使用

private void onCropImg(Intent data) 
    { 
     Bitmap bm = (Bitmap) data.getExtras().get("data"); 
     ByteArrayOutputStream stream = new ByteArrayOutputStream(); 
     bm.compress(Bitmap.CompressFormat.JPEG, 75, stream); 

     Uri tempUri = getImageUri(csActivity,bm); 

      // CALL THIS METHOD TO GET THE ACTUAL PATH 
     File destination = new File(getRealPathFromURI(tempUri)); 

     csProfileImg.setImageBitmap(bm); 

     uploadProfileImg(destination); 
     } 

,並getImageUri

public Uri getImageUri(Context inContext, Bitmap inImage) { 
     ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
     inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); 
     String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null); 
     return Uri.parse(path); 
    } 

請幫我

回答

0

您可以使用庫來裁剪圖像,將給予適當的結果與影像品質。使用方法:compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'

而對於更多的,你可以訪問此頁:check my answer