【发布时间】:2019-01-17 13:27:35
【问题描述】:
我今天真的需要你的帮助!我正在调试由另一个开发人员创建的旧 Objective-c 应用程序,并且有一个仅出现在 iOS 11 上的新错误。
该错误来自尝试创建“Scratch View”时使用的图像处理功能,类似于此 -> https://github.com/joehour/ScratchCard
但是,从 iOS 11 开始,该功能不再起作用,在上面的代码中,[Unknown process name] CGImageMaskCreate: invalid image provider: NULL. 出现错误
// Method to change the view which will be scratched
- (void)setHideView:(UIView *)hideView
{
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
UIGraphicsBeginImageContextWithOptions(hideView.bounds.size, NO, 0);
[hideView.layer renderInContext:UIGraphicsGetCurrentContext()];
hideView.layer.contentsScale = scale;
_hideImage = UIGraphicsGetImageFromCurrentImageContext().CGImage;
UIGraphicsEndImageContext();
size_t imageWidth = CGImageGetWidth(_hideImage);
size_t imageHeight = CGImageGetHeight(_hideImage);
CFMutableDataRef pixels = CFDataCreateMutable(NULL, imageWidth * imageHeight);
_contextMask = CGBitmapContextCreate(CFDataGetMutableBytePtr(pixels), imageWidth, imageHeight , 8, imageWidth, colorspace, kCGImageAlphaNone);
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(pixels);
CFRelease(pixels);
CGContextSetFillColorWithColor(_contextMask, [UIColor blackColor].CGColor);
CGContextFillRect(_contextMask, self.frame);
CGContextSetStrokeColorWithColor(_contextMask, [UIColor whiteColor].CGColor);
CGContextSetLineWidth(_contextMask, _sizeBrush);
CGContextSetLineCap(_contextMask, kCGLineCapRound);
CGImageRef mask = CGImageMaskCreate(imageWidth, imageHeight, 8, 8, imageWidth, dataProvider, nil, NO);
_scratchImage = CGImageCreateWithMask(_hideImage, mask);
CGDataProviderRelease(dataProvider);
CGImageRelease(mask);
CGColorSpaceRelease(colorspace);
}
我不是这个图像处理功能的专家,我真的迷失了调试这部分...... 有谁知道为什么这个功能在 iOS 11 中不再起作用?
感谢您的帮助!
【问题讨论】:
标签: objective-c image-processing ios11