I get exc_bad_access in the line CIContext *context = [CIContext contextWithOptions:nil];
I turned on the zombies and checked with the tools: No luck.
Full code:
- (UIImage *) doBinarize:(UIImage *)sourceImage withThreshold:(float)threshold { UIImage *newImage; if (sourceImage){ CIContext *context = [CIContext contextWithOptions:nil]; CIImage *image = [[CIImage alloc] initWithImage:sourceImage]; CIImage *cImg = [self AdaptiveThresholdFilter:image withThreshold:threshold]; CIImage *ciImage = cImg; CGImageRef cgImage = [context createCGImage:ciImage fromRect:CGRectMake(0, 0, sourceImage.size.width, sourceImage.size.height)]; newImage = [UIImage imageWithCGImage:cgImage]; CGImageRelease(cgImage); } else { return nil; } return newImage; }
However, I am almost everywhere where I put the CIContext contextWithOptions line, the application will crash there.
This is on iOS8.1, iPhone 5C. It should be noted that on iOS9 or iOS10 there are no problems.
Any suggestions?
ios ios8 core-image exc-bad-access
Elliott malone
source share