简体   繁体   English

以人像模式拍摄的照片是否沿逆时针方向旋转保存?

[英]Picture taken on portrait mode is saved rotated counter clockwise?

I'm building a camera app, I'm requesting the camera instance this way and the preview is shown in the right angle: 我正在构建相机应用程序,以这种方式请求相机实例,并且预览以直角显示:

        c = Camera.open();
        c.setDisplayOrientation(90);

However after the user takes a photo and loading it into an imageView it's rotated 90 degrees counter clockwise. 但是,在用户拍摄照片并将其加载到imageView后,它会逆时针旋转90度。 This is how I save the photo: 这是我保存照片的方式:

    @Override
    public void onPictureTaken(byte[] data, Camera camera) {
        try {
            String filePath = folderPath + generateFileName();
            FileOutputStream outStream = new FileOutputStream( filePath );
            outStream.write(data);
            outStream.close();
            // Put into imageView
            File file = new  File(filePath);
            if(file.exists()){
                Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
                last_photo.setImageBitmap(myBitmap);
            }
        } catch (FileNotFoundException e) {
        } catch (IOException e) {
        } finally {
        }
    }

How can I save the image without it being rotated? 如何在不旋转图像的情况下保存图像?

I think you want to use setRotation() instead, or in addition to, setDisplayOrientation() . 我认为您想使用setRotation()代替setDisplayOrientation()或除setDisplayOrientation() That method is described here 该方法在这里描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM