Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 Core Image QR Code generation too blur

Tags:

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?

like image 512
OMGPOP Avatar asked Mar 13 '14 10:03

OMGPOP


People also ask

How do I increase the resolution of a 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.

Why does my QR code look different?

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.

What resolution are QR codes?

Resolution requirements For QR Codes So, the resolution required for any QR Code to be reliably read is 38 x 38 pixels.

How do I resize a QR code without losing quality?

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.

How to generate QR code on iOS 7?

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.

How to generate a QRcode image?

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.

How do I change the size of the QRcode?

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.

Why is the textfield on the QR code slider always visible?

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.


1 Answers

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

enter image description here

(it doesn't seem to work on simulator but works great on real device

like image 117
Lope Avatar answered Jan 04 '23 01:01

Lope