簡體   English   中英

自定義相機中的三星設備中的圖像保存問題

[英]issue on image saving in samsung devices in custom camera

我正在開發使用自定義攝像頭的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();
            }
        }

我已經用以下代碼解決了這個問題:

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);
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM