iOS 7 Core Image QR Code 生成太模糊 [英] iOS 7 Core Image QR Code generation too blur
本文介绍了iOS 7 Core Image QR Code 生成太模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我生成二维码图片的代码
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屋!
查看全文