【问题标题】:Encoded QR and Aztec barcodes contain blur/dither编码的 QR 和 Aztec 条形码包含模糊/抖动
【发布时间】:2017-04-27 22:30:53
【问题描述】:

我正在使用 ZXingObjC 库的最新版本 (3.2.1) 在 iOS 应用程序中生成 QR 和 Aztec 条形码。我正在使用与库的“编码”示例相同的代码,即:

NSError *error = nil;
ZXMultiFormatWriter *writer = [ZXMultiFormatWriter writer];
ZXBitMatrix* result = [writer encode:@"A string to encode"
                              format:kBarcodeFormatQRCode
                               width:200
                              height:200
                               error:&error];

CGImageRef imageRef = [[ZXImage imageWithMatrix:result] cgimage];
UIImage *image = [UIImage imageWithCGImage:imageRef];
myImageView.image = image;

但是,我看到使用上述代码在我的UIImageView 中呈现的条形码在从黑色块过渡到白色块时包含一些模糊/抖动。这是不可取的,并且可能会影响扫描速度最重要的环境中的扫描速度。这是一个放大条形码的示例,以使问题更加明显:

问题:在我的 iOS 应用程序中生成/呈现条形码时,我可以做些什么来避免这种模糊/抖动??

请注意,我已将 UIImageView 的内容模式指定为居中 (UIViewContentModeCenter),这样它就不会缩放包含的图像,因此我无法想象 UIImageView 会导致模糊/抖动.

顺便说一句:我在 Android 应用程序中使用了等效的 com.google.zxing:core:3.3.0 库,但我没有在那里看到同样的问题。请参阅以下 Android 应用程序中条形码的放大屏幕截图:

【问题讨论】:

    标签: ios uiimageview uiimage zxing zxingobjc


    【解决方案1】:

    在其他几台设备(iPhone 5s 和 iPhone 7)上对此进行测试后,我意识到这是 iPhone 6+ 特有的问题。事实证明,iPhone 6+ 的“物理”分辨率(1080 x 1920 像素)小于“虚拟”分辨率(1242 x 2208 像素)(参见here),因此 iPhone 6+ 对显示,这就是导致模糊/抖动的原因。可悲的是,我认为对此无能为力...除非有人有任何建议??

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-04
      相关资源
      最近更新 更多