简体   繁体   English

如何在Android中恢复前置摄像头的翻转图片?

[英]How to revert back the flipped picture from front camera in android?

Can not figure out for couple of days now how to resolve my flipped picture from front camera on Android 4. 现在无法弄清楚如何在Android 4上从前置摄像头解析我的翻转图片。

I want to rotate them on this way, but for some reason android don`t detect rule for front facing camera and OS version. 我想以这种方式旋转它们,但由于某种原因,android不会检测前置摄像头和操作系统版本的规则。

    public static float getDegree(int exifOrientation) {
    if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90)
        return 180;
    else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180)
        return 270;
    else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270)
        return 0;

    Camera.CameraInfo info = new Camera.CameraInfo();
    android.hardware.Camera.getCameraInfo(0, info);
    if (android.os.Build.VERSION.SDK_INT>13 && info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
    {
        return 270;
    }
    else {
        return 90;
    }

Any suggestions? 有什么建议么?

Create two arrays: one that contains the data for vertical lines and one for temporary data (they should have the same size). 创建两个数组:一个包含垂直线的数据,另一个包含临时数据(它们应具有相同的大小)。 Then create a loop where you start from the length of the first array and go to 0. On every iteration, add the data from that vertical line array to the another one. 然后创建一个循环,从第一个数组的长度开始,然后转到0.在每次迭代时,将该垂直线数组中的数据添加到另一个数组。 Then just convert the temporary array to an image if you will. 然后,只要将临时数组转换为图像即可。

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

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