2014-08-29 63 views
0

我正在開發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(); 
      } 
     } 

回答

0

我已經解決了這個問題,此代碼:

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); 
    } 
} 
相關問題