当前位置: 代码迷 >> 综合 >> zxing 扫描二维码变形问题
  详细解决方案

zxing 扫描二维码变形问题

热度:60   发布时间:2023-09-28 22:23:59.0

修改 CameraConfigurationManager类中void initFromCameraParameters(Camera camera)方法;

如下:

Camera.Parameters parameters = camera.getParameters();
    previewFormat = parameters.getPreviewFormat();
    previewFormatString = parameters.get("preview-format");
    Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    screenResolution = new Point(display.getWidth(), display.getHeight());
    Log.d(TAG, "Screen resolution: " + screenResolution);
//    cameraResolution = getCameraResolution(parameters, screenResolution);
//    Log.d(TAG, "Camera resolution: " + screenResolution);


    Point screenResolutionForCamera = new Point();
    screenResolutionForCamera.x = screenResolution.x;
    screenResolutionForCamera.y = screenResolution.y;
    // preview size is always something like 480*320, other 320*480
    if (screenResolution.x < screenResolution.y) {
      screenResolutionForCamera.x = screenResolution.y;
      screenResolutionForCamera.y = screenResolution.x;
    }
    cameraResolution = getCameraResolution(parameters, screenResolutionForCamera);