在将照片保存到文件之前回调以操作照片

时间:2015-02-15 11:01:09

标签: android android-intent camera android-camera

在将文件保存到文件之前,我想拍照并压缩它的大小。 根据我从android开发人员指南中了解到的,我只能先将照片保存到文件然后压缩它。

File photoFile = //aquire file path to the saved photo...
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                        Uri.fromFile(photoFile));
                startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
...
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.i("addNewActivity","onActivityResult");
        if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {
          Bitmap bm = BitmapFactory.decodeFile(photoFile.getAbsolutePath());
          //...compress the photo and re-save it again to the file.
        }
    } 

这种流程的最佳做法是什么?我无法回调图像的字节[],并在 将其保存到文件之前对其进行操作吗?

0 个答案:

没有答案
相关问题