【问题标题】:issue on image saving in samsung devices in custom camera自定义相机中三星设备中图像保存的问题
【发布时间】:2014-10-10 20:48:27
【问题描述】:

我正在开发使用自定义相机的 android 应用程序,我的相机方向是纵向,但图像保存在横向和图像划痕上,并接受三星所有设备正常工作,请提前给我任何解决方案谢谢。 这是我设置相机方向的方法。

    public void updateCameraRotation(){
            try {
                Camera.CameraInfo info = new Camera.CameraInfo();
                Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, info);
                int rotation = this.getWindowManager().getDefaultDisplay().getRotation();
                int degrees = 0;
                switch (rotation) {
                case Surface.ROTATION_0: degrees = 0; break; //Natural orientation
                case Surface.ROTATION_90: degrees = 90; break; //Landscape left
                case Surface.ROTATION_180: degrees = 180; break;//Upside down
                case Surface.ROTATION_270: degrees = 270; break;//Landscape right
                }
                int rotate = (info.orientation - degrees + 360) % 360;
                Camera.Parameters params = myCamera.getParameters();
                params.setRotation(rotate); 
                myCamera.setParameters(params);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

【问题讨论】:

    标签: android camera


    【解决方案1】:

    我已经用这段代码解决了这个问题:

    deviceName=Util.getInstance().getDeviceName();
    if(deviceName.contains("Samsung")||deviceName.equalsIgnoreCase("Samsung")){
        if (bitmap.getWidth() > bitmap.getHeight()) {
            Matrix matrix = new Matrix();
            matrix.postRotate(90);
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-06
      • 2018-05-26
      • 1970-01-01
      • 1970-01-01
      • 2018-12-24
      相关资源
      最近更新 更多