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?
For every 5 rows and columns of your QR code, you can increase its size by about . 2” to ensure a 12” scan distance.
Even if two QR Codes store identical data, the pattern might or might not be different depending on the QR Code generator used. The primary reason for the change is due to the internal expression of the QR Code (numeric code, alphanumeric code, and so on). If this expression varies, then the data pattern also varies.
Resolution requirements For QR Codes So, the resolution required for any QR Code to be reliably read is 38 x 38 pixels.
Press the Ctrl+R hotkey to open the Resize/Resample window. Enter your desired dimensions in pixels or percentages to resize the QR code without losing quality.
To make it perfectly clear, since iOS 7 a QR code is generated as a CIImage object ( CoreImage image) simply by using a special filter named CIQRCodeGenerator. All it takes is to provide the data that you want to convert into a QR code image, and iOS will manage and do the heavy work.
Run it, add some text, and then use the Generate button to create a new QRCode image. As you can see to the next screenshot, this time the output is much more clear, and has nothing to do with the blurry result we had up until now. At this point you have all you need to know about generating a QRCode image.
What we want to do is to scale down the image view by sliding to the left, and scale up when sliding to the right. When reaching the maximum value, the image view will be shown double-sized, meaning that the QRCode will look larger.
The first one is the fact that the slider doesn’t become hidden once you remove the QR code, instead it stays always visible. The second one is that the textfield is editable even you’ve created a QR code, and that makes the keyboard appear even when you don’t need it.
Easiest solution is to add following to your image view:
imgViewQR.layer.magnificationFilter = kCAFilterNearest
This will automatically upscale your generated QR code image to imageview's size using nearest
which results in sharp, pixelated image. This usually isn't what you want when resizing icons/photos but is perfect for QR codes
(it doesn't seem to work on simulator but works great on real device
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With