【发布时间】:2017-04-05 23:04:57
【问题描述】:
在我的 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图像),并且大小是相同的。
【问题讨论】:
标签: ios objective-c iphone uiimage