在我的iPhone应用程序中,我总是使用以下函数对图像进行horizontally mirror。
-(UIImage*)mirrorImage:(UIImage*)img
{
CIImage *coreImage = [CIImage imageWithCGImage:img.CGImage];
coreImage = [coreImage imageByApplyingTransform:CGAffineTransformMakeScale(-1, 1)];
img = [UIImage imageWithCIImage:coreImage scale:img.scale orientation:UIImageOrientationUp];
return img;
}但是,对于iOS 10.0.1,该函数仍然没有错误地运行,但是当我尝试使用该函数的UIImage时,会出现以下警告,图像似乎不存在。
Failed to render 921600 pixels because a CIKernel's ROI function did not allow tiling.当我尝试使用UIImage时,这个错误实际上会出现在输出窗口中(在这段代码的第二行):
UIImage* flippedImage = [self mirrorImage:originalImage];
UIImageView* photo = [[UIImageView alloc] initWithImage:flippedImage];调用mirrorImage之后,flippedImage变量确实包含一个值,它不是nil,但是当我尝试使用该图像时,我会得到该错误消息。
如果我不调用mirrorImage函数,那么代码可以正常工作:
UIImageView* photo = [[UIImageView alloc] initWithImage:originalImage];iOS 10是否有一些新的怪癖会使我的mirrorImage功能无法工作?
添加一下,在mirrorImage函数中,我尝试在转换前后测试图像的大小(因为错误抱怨必须对图像进行tile ),并且大小是相同的。
发布于 2017-01-16 02:03:56
我通过转换CIImage -> CGImage -> UIImage来修复它
let ciImage: CIImage = "myCIImageFile"
let cgImage: CGImage = {
let context = CIContext(options: nil)
return context.createCGImage(ciImage, from: ciImage.extent)!
}()
let uiImage = UIImage(cgImage: cgImage)发布于 2016-11-22 10:20:27
不要紧。
我不知道iOS 10坏了什么,但我设法用以下方法替换了我的函数,从而解决了这个问题:
-(UIImage*)mirrorImage:(UIImage*)img
{
UIImage* flippedImage = [UIImage imageWithCGImage:img.CGImage
scale:img.scale
orientation:UIImageOrientationUpMirrored];
return flippedImage;
}https://stackoverflow.com/questions/40739037
复制相似问题