Android Camera Photo Thumbnail Orientation

旧巷老猫 提交于 2020-02-24 19:41:06

问题


We have been using a bunch of code that uses the camera with the desired end result, but I want to get to the bottom of this with clean code. I'm simply following the Android docs here verbatim, and getting a rotated thumbnail. Below is the code, please find the working project in this branch of my Bitbucket repository.

private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        Bitmap imageBitmap = (Bitmap) extras.get("data");

        ImageView view = (ImageView) findViewById(R.id.imageView);

        view.setImageBitmap(imageBitmap);
    }
}

I know that this is just the thumbnail. But it seems the thumbnail is completely useless, unless you get the full file and read the exif info from that.

I know that StackOverflow says "get the exif rotation from the full image file and rotate the actual bitmap before recompressing it into another jpg file". But isn't this a little too much unnecessary computation? What good is the thumbnail if it's useless by itself without getting the orientation from the full file?

Am I missing something?

来源:https://stackoverflow.com/questions/44501550/android-camera-photo-thumbnail-orientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!