iOS 10:CIKernel的ROI功能不允许平铺 [英] iOS 10: CIKernel's ROI function did not allow tiling

查看:57
本文介绍了iOS 10:CIKernel的ROI功能不允许平铺的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序中,我一直使用以下功能来horizontally mirror图片.

In my iPhone app, I've always used the following function to horizontally mirror an image.

-(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时,会出现以下警告,并且图像似乎不存在. /p>

With iOS 10.0.1 though, this function still runs with no errors, but when I try to use the UIImage from this function, the following warning appears, and the image just doesn't seem to be there.

Failed to render 921600 pixels because a CIKernel's ROI function did not allow tiling.

当我尝试使用 UIImage(在此代码的第二行)时,此错误实际上出现在输出"窗口中:

This error actually appears in the Output window when I attempt to use the UIImage (in the second line in this code) :

UIImage* flippedImage = [self mirrorImage:originalImage];    
UIImageView* photo = [[UIImageView alloc] initWithImage:flippedImage];

在调用mirrorImage之后,flippedImage变量确实包含一个值,它不是nil,但是当我尝试使用该图像时,会收到该错误消息.

After calling mirrorImage, the flippedImage variable does contain a value, it's not nil, but when I try to use the image, I get that error message.

如果我不调用 mirrorImage函数,那么代码可以正常工作:

If I were to not call the mirrorImage function, then the code works fine:

UIImageView* photo = [[UIImageView alloc] initWithImage:originalImage];

使用iOS 10是否有一些新问题会阻止我的mirrorImage函数正常工作?

Is there some new quirk with iOS 10 which would prevent my mirrorImage function from working ?

只需在mirrorImage函数中添加,我尝试在转换之前和之后测试图像的大小(因为错误抱怨必须tile图像),并且大小是相同的. /p>

Just to add, in the mirrorImage function, I tried testing the size of the image before and after the transformation (as the error is complaining about having to tile the image), and the size is identical.

推荐答案

我通过转换CIImage-> CGImage-> UIImage

I fixed it by converting 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的ROI功能不允许平铺的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆