• Android之Zxing二维码扫描图片拉伸


    还是这个接手项目,二维码扫描集成的是zxing,扫描界面的图像有明显的拉伸变形。

    这种问题,根据以往的经验,一般是x,y轴错位引起的,处理好x,y轴的问题,一般可以解决问题。

    由于这个问题,之前有很多人遇到,并分享在网上了,所以,我这里也就不需要重复造轮子了。

    这里看了一篇博客:http://blog.csdn.net/aaawqqq/article/details/24852915,用了上面的办法,

    成功的解决图片拉伸问题。

    解决方法如下:

    修改CameraConfigurationManager.Java里面的initFromCameraParameters方法:

    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);
    
        //added
        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);
    
    //    cameraResolution = getCameraResolution(parameters, screenResolution);
        Log.d(TAG, "Camera resolution: " + screenResolution);
      }
    View Code
     
  • 相关阅读:
    vue.js初识(一)
    node.js安装
    array_unshift
    查看php 某个服务的进程数
    获取src 内容
    微信支付 composer 方法 --- 实测有效
    tp5.1 model 方法下的like语句查询
    tp5.1 where 时间查询
    nginx conf 文件
    怎么用Ubuntu系统制作Ubuntu系统盘
  • 原文地址:https://www.cnblogs.com/shenchanghui/p/6991733.html
Copyright © 2020-2023  润新知