【问题标题】:zxing Data matrix gets blurred when scaledzxing 数据矩阵在缩放时变得模糊
【发布时间】:2017-08-26 10:33:17
【问题描述】:

有没有办法让数据矩阵在 UIView 中缩放时不被模糊,宽度和高度只会使数据矩阵更复杂,我想要 16x16 点,但是当我让它更大时,它分为 4 个单元格。数据矩阵的扫描速度非常快,但设计师希望它像素完美。

   ZXMultiFormatWriter *writer = [ZXMultiFormatWriter writer];
if (writer && self.myString.length) {

    ZXBitMatrix *result = [writer encode:self.myString
                                  format:kBarcodeFormatDataMatrix
                                   width:16
                                  height:16 error:&error];
    if (result) {
        ZXImage *zxImage = [ZXImage imageWithMatrix:result];

        if (zxImage) {
            CGImageRef cgImage = [zxImage cgimage];
            if (cgImage) {
                UIImage *barCodeImage = [UIImage imageWithCGImage:cgImage];
                if (barCodeImage) {
                    self.barcodeImageView.image = barCodeImage;
                    [self showDataMatrixHideBarcode];
                }
            }
        }

【问题讨论】:

    标签: objective-c zxing


    【解决方案1】:

    可能会添加:

    [[self.barcodeImageView layer] setMagnificationFilter:kCAFilterNearest];
    

    在imageView上设置图像之前是你想要的。

    别忘了补充:

    #import <QuartzCore/CALayer.h> 
    

    到你的文件!

    【讨论】:

      【解决方案2】:

      我们就是这样解决的

        self.dataMatrixImageView.layer.magnificationFilter = kCAFilterNearest;
        self.dataMatrixImageView.image = dataMatrixImage;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-04-21
        • 2014-08-30
        • 1970-01-01
        • 2013-05-09
        • 2021-10-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多