Reputation: 1823
I have the error:
initQRCodeForInputByteSize cannot find proper rs block info (input data too big?)
when I generate the QR code.
Here is the code:
NSData *stringData = [qrString dataUsingEncoding: NSISOLatin1StringEncoding];
CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[qrFilter setValue:stringData forKey:@"inputMessage"];
[qrFilter setValue:@"L" forKey:@"inputCorrectionLevel"];
CIImage *qrCodeImage = qrFilter.outputImage;
Does anyone know how to solve the problem?
Upvotes: 1
Views: 881
Reputation: 2498
The error is giving you a big hint, the data you are trying to transform into a QR is too big.
QR Capacity
As obvious as it sounds the solution is to reduce the amount of data, if you cannot renounce to this amount of data you could just use the QR to encode an URL pointing to the bulk of the data hosted somewhere else.
Upvotes: 1
Reputation: 1736
When posting on StackOverflow you should include a full code sample and not just the first five lines from the tutorial you're using. This allows, as developers to get some context as to what you've tried and the source of your problem.
Code pulled from here
NSString *info = @"http://codeafterhours.wordpress.com";
// Generation of QR code image
NSData *qrCodeData = [info dataUsingEncoding:NSISOLatin1StringEncoding]; // recommended encoding
CIFilter *qrCodeFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[qrCodeFilter setValue:qrCodeData forKey:@"inputMessage"];
[qrCodeFilter setValue:@"M" forKey:@"inputCorrectionLevel"]; //default of L,M,Q & H modes
CIImage *qrCodeImage = qrCodeFilter.outputImage;
CGRect imageSize = CGRectIntegral(qrCodeImage.extent); // generated image size
CGSize outputSize = CGSizeMake(240.0, 240.0); // required image size
CIImage *imageByTransform = [qrCodeImage imageByApplyingTransform:CGAffineTransformMakeScale(outputSize.width/CGRectGetWidth(imageSize), outputSize.height/CGRectGetHeight(imageSize))];
UIImage *qrCodeImageByTransform = [UIImage imageWithCIImage:imageByTransform];
self.imgViewQRCode.image = qrCodeImageByTransform;
If this works it would indicate to me that you are declaring your 'qrString' variable incorrectly. If you could share that with us it would help.
Upvotes: 0