iOS 7 Core Image QR Code生成太模糊 [英] iOS 7 Core Image QR Code generation too blur

查看:80
本文介绍了iOS 7 Core Image QR Code生成太模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我用于生成QRCode图像的代码

here's my code for generating QRCode image

+ (UIImage *)generateQRCodeWithString:(NSString *)string {
    NSData *stringData = [string dataUsingEncoding:NSUTF8StringEncoding];
    CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
    [filter setValue:stringData forKey:@"inputMessage"];
    [filter setValue:@"M" forKey:@"inputCorrectionLevel"];
    return [UIImage imageWithCIImage:filter.outputImage];
}

结果太模糊。是否可以设置生成的二维码的大小?

The result is too blur. Is it possible to set the size of the generated qr code?

推荐答案

我本来打算悬赏这个问题,但我找到了答案。

I was about to start bounty on this question but i found the answer.

您需要的是一个比例过滤器。要使用CoreImage实现此目的,您需要执行以下操作:

What you need is a scale filter. To achieve this with CoreImage, you need to do something like this:

CIImage *input = [CIImage imageWithCGImage: ImageView.Image.CGImage]; // input image is 100 X 100
CGAffineTransform transform = CGAffineTransformMakeScale(5.0f, 5.0f); // Scale by 5 times along both dimensions
CIImage *output = [input imageByApplyingTransform: transform];
// output image is now 500 X 500

从以下答案: https://stackoverflow.com/a/16316701/2859764

这篇关于iOS 7 Core Image QR Code生成太模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆