1

私は現在、クロップ機能に入るときに私のギャラクシーネクサスが「画像の読み込み」をループし続けるという問題に直面しています.以下は私のコーディングです:

Intent openCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
startActivityForResult(openCamera, click_camera);

protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent){
            if (imageReturnedIntent != null)
                {if(requestCode == click_camera && resultCode == RESULT_OK) { 
                    picUri = imageReturnedIntent.getData();
                    Crop();             
                }

            else {
                **my coding part**
}

/* crop method */
private void Crop(){    
    try {

        //call the crop action from intent (default from device)
        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", 300);
        cropIntent.putExtra("outputY", 300);
        cropIntent.putExtra("scale", true);
        cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
        cropIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
        //retrieve data on return
        cropIntent.putExtra("return-data", true);
        //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();
    }
}

それは私のクロップ機能が間違っていますか?誰が何がうまくいかないのを助けることができますか?

4

1 に答える 1

2

これが、自分の状況で問題を解決した方法です。

これを取る:

cropIntent.putExtra("outputX", 300);
cropIntent.putExtra("outputY", 300);

そして変更:

cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);

理由:ここをクリック

編集

私は解決策を見つけました

設定

cropIntent.putExtra("outputX", ANY VALUE);
cropIntent.putExtra("outputY", ANY VALUE);
cropIntent.putExtra("return-data", false);
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri);

トリミングされた画像を見る

BitmapFactory.decodeFile(mImageCaptureUri.getPath());

楽しみ :)

于 2013-02-05T15:30:38.343 に答える