iOS 10 : CIKernel's ROI function did not allow tiling

标签 ios objective-c iphone uiimage

在我的 iPhone 应用程序中,我一直使用以下函数来水平镜像图像。

-(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图像),并且大小相同。

最佳答案

我通过转换 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)

关于iOS 10 : CIKernel's ROI function did not allow tiling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40739037/

相关文章:

objective-c - 强制子类在 Objective-C 中调用其父类(super class)方法

ios - 不明白苹果 watch 配套应用程序是如何安装的

ios - AWSFirehoseRecorder saveRecord 似乎从不保存任何记录

ios - RPScreenRecorder 记录警报文本更改

ios - 如何在Shopify中保持用户登录状态或检查用户是否登录?

objective-c - 在 NSTableCellView 中定位文本

ios - 对 LoginManager Facebook sdk swift 的模糊引用

iphone - 在 UINavigationController 层次结构中刷新 UITableView 的最佳方法是什么

iphone - 换行符在 UI​​Label 中不起作用

iphone - 音频可以在 3.2 sim 中播放,但不能在 4.x 中播放