4

ユーザーがギャラリーから選択した画像を切り抜こうとすると、プログラムで問題が発生します。これまでのところ、この問題はDroid Xで実行している場合にのみ発生します。これは、元のmotoDroidで実行すると正常に機能するためです。

基本的に、この問題は、トリミングインテントが実行されているときに発生します。ユーザーが写真を切り抜いて保存ボタンをクリックすると、メイン画面の壁紙が保存された切り抜かれた画像に置き換えられます。モトドロイドやエミュレーターではこれを行いません。以下は、画像をトリミングしてSDカードに保存するためのコードです。

@Override
public void onActivityResult(int requestCode,int resultCode,Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode ==1){
if (resultCode == Activity.RESULT_OK) {
  Intent i = new Intent("com.android.camera.action.CROP");
  i.setData(data.getData());
  i.putExtra("noFaceDetection", true);
  i.putExtra("outputX", 80);
  i.putExtra("outputY", 80);
  i.putExtra("aspectX", 1);
  i.putExtra("aspectY", 1);
  i.putExtra("scale", true);


if(selectedImageString == null){
      ContentValues values = new ContentValues();
      values.put(android.provider.MediaStore.Images.Media.TITLE, "Temp_Icon1");
      values.put(android.provider.MediaStore.Images.Media.BUCKET_ID, "Temp_Icons");
      values.put(android.provider.MediaStore.Images.Media.BUCKET_DISPLAY_NAME,"Temp_Icons");
      values.put(android.provider.MediaStore.Images.Media.IS_PRIVATE, 1);
      selectedImageString = getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values).toString();
  }
  i.putExtra("output", Uri.parse(selectedImageString));
  startActivityForResult(i, 2);
}
}
 if(requestCode == 2){
 if (resultCode == Activity.RESULT_OK){
  uriPath = Uri.parse(selectedImageString);
  imageView.setImageURI(uriPath);
 }
}

}

誰かがこれを手伝ってくれませんか?

4

3 に答える 3

3

I can verify that the Droid X is doing the same for me even with the "output" option mentioned above. I have found no way around it as of yet and will look at blocking the crop feature for Droid X phones as well. It is ashame it doesn't work here.

By they way, you could try the following...

i.putExtra("return-data", true);

This returns the image in the returned intent. You can access it with the following...

BitMap BM = data.getParcelableExtra("data");

This, however, is not supported by the Galaxy S line of phones. It returns an empty parcel no matter what. So, I have found no good solution yet.

于 2010-10-06T18:39:50.277 に答える
1

切り取りインテントを呼び出すときにデータを配置する場所を指定していないため、画像が上書きされている可能性があります。

クロップ インテントは内部コードだと思いますので、確実に知ることができるかどうかはわかりません (クロップ インテントはすべての電話で見つかるわけではありません)。

クロップインテントを呼び出すと、パスします

i.putExtra("output", croppedOutputUri);
于 2010-09-17T15:38:24.893 に答える
0

配置しようとしましたか:

i.putExtra("setWallpaper", false);

ここから取得しました: https://github.com/lvilani/android-cropimage/blob/master/src/com/android/camera/CropImage.java

おそらく元のソースからタキエンされて変更されたライブラリがあり、この属性がそこに設定されていることがわかります

于 2013-07-08T11:27:41.347 に答える