0

画像の保存に関する問題についてサポートが必要です。Adobe Photo SDK を使用して画像を編集しています。ドキュメント リンク ( https://creativesdk.adobe.com/docs/android/#/articles/imageediting/index.html )。彼らは、作成した画像を保存するために .withOutput(Uri) を使用すると言いますが、エラーで画像を取得します。

public class MainActivity extends AppCompatActivity {
    private static final int IMG_CODE_EDIT = 263;
    private Button mPickbtn;
    private Button mCapturebtn;
    private static int RESULT_LOAD_IMAGE = 1;
    private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
    private String mCurrentPhotoPath;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mPickbtn = (Button) findViewById(R.id.pick_image);
        mCapturebtn = (Button) findViewById(R.id.button2);

        Intent cdsIntent = AdobeImageIntent.createCdsInitIntent(getBaseContext(), "CDS");
        startService(cdsIntent);

    }

    public void takePicture(View view) {
        // create Intent to take a picture and return control to the calling application
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        // start the image capture Intent
        startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    }

    public void onClick(View view) {

        Intent i = new Intent(
                Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

        startActivityForResult(i, RESULT_LOAD_IMAGE);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        //Gets the gallery image uri
        if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
            Uri selectedImage = data.getData();
            String[] filePathColumn = {MediaStore.Images.Media.DATA};

            Cursor cursor = getContentResolver().query(selectedImage,
                    filePathColumn, null, null, null);
            cursor.moveToFirst();

            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String picturePath = cursor.getString(columnIndex);
            cursor.close();

            editPic(selectedImage);
        } 

        //picture from camera
        if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                Uri mPicTaken = data.getData();
                editPic(mPicTaken);
            } else if (resultCode == RESULT_CANCELED) {
                // User cancelled the image capture
            } else {
                // Image capture failed, advise user
            }
        }

        if (resultCode == RESULT_OK) {
            switch (requestCode) {

                /* 4) Make a case for the request code we passed to startActivityForResult() */
                case 263:

                    /* 5) Show the image! */
                    Uri editedImageUri = data.getData();
                    Intent intent = new Intent("com.ayyogames.photoapp.Share");
                    intent.putExtra("imageUri", editedImageUri);
                    startActivity(intent);

                    break;
            }
        }

    }

public void editPic(Uri uri) {

        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
        }

        if (photoFile != null) {
            Uri photoURI = FileProvider.getUriForFile(this,
                    "com.ayyogames.photoapp.fileprovider",
                    photoFile);

            Intent intent = new AdobeImageIntent.Builder(this)
                    .setData(uri)
                    .withOutputSize(MegaPixels.Mp10)
                    .withOutputQuality(100)
                    .withOutput(photoURI)
                    .build();

            startActivityForResult(intent, IMG_CODE_EDIT);
        }
    }


private File createImageFile() throws IOException {
        // Create an image file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        String imageFileName = "JPEG_" + timeStamp + "_";
        File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
        File image = File.createTempFile(
                imageFileName,  /* prefix */
                ".jpg",         /* suffix */
                storageDir      /* directory */
        );

        // Save a file: path for use with ACTION_VIEW intents
        mCurrentPhotoPath = "file:" + image.getAbsolutePath();
        return image;
    }

シェアクラス

public class Share extends AppCompatActivity {

    private ImageView mEditedImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_share);

        Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
        setSupportActionBar(myToolbar);
        ActionBar ab = getSupportActionBar();
        ab.setDisplayHomeAsUpEnabled(true);

        mEditedImageView = (ImageView) findViewById(R.id.editedImageView);

        Intent intent = getIntent();
        Uri uri = intent.getParcelableExtra("imageUri");

        mEditedImageView.setImageURI(uri);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main_menu,menu);

        return true;
    }
}
4

1 に答える 1

0

Image Editor デベロッパー ガイドUriでは現在、 toを渡す必要があると記載されていますがwithOutput()、これは正しくありません。

を渡してみてくださいFile:

    /* 1) Change the argument to your desired location */
    File file = new File(Environment.getExternalStorageDirectory() + File.separator + "test.jpg");
    try {
        file.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Intent imageEditorIntent = new AdobeImageIntent.Builder(this)
            .setData(imageUri)
            .withOutput(file) /* 2) Pass the File here */
            .build();

コンストラクターへの引数は、File任意の場所に変更する必要があります。

于 2016-07-11T15:35:23.717 に答える