ios - 当 scaleKey 大于某个值时,Lanczos 比例不起作用

标签 ios ios7 uiimage cifilter lanczos

我有这个代码

CIImage * input_ciimage = [CIImage imageWithCGImage:self.CGImage];
CIImage * output_ciimage =
[[CIFilter filterWithName:@"CILanczosScaleTransform" keysAndValues:
                           kCIInputImageKey, input_ciimage,
                           kCIInputScaleKey, [NSNumber numberWithFloat:0.72], // [NSNumber numberWithFloat: 800.0 / self.size.width],
                           nil] outputImage];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef output_cgimage = [context createCGImage:output_ciimage 
    fromRect:[output_ciimage extent]];
UIImage *output_uiimage;
output_uiimage = [UIImage imageWithCGImage:output_cgimage 
    scale:1.0 orientation:self.imageOrientation];
CGImageRelease(output_cgimage);
return output_uiimage;

因此,当 scaleKey 大于某个值时,output_uiimage 为黑色图像。

在我的例子中,如果键 kCIInputScaleKey 的值 > @0.52 那么结果是黑色图像。当我将图像旋转 90 度时,我得到了相同的结果,但值为 0.72(而不是 0.52)。

库有什么问题或我的代码有错误吗?

如果需要,我有 iPhone 4、iOS 7.1.2 和 xCode 6.0。

最佳答案

Apple 是这么说的:

This scenario exposes a bug in Core Image. The bug occurs when rendering requires an intermediate buffer that has a dimension greater than the GPU texture limits (4096) AND the input image fits into these limits. This happens with any filter that is performing a convolution (blur, lanczos) on an input image that has width or height close to the GL texture limit.
Note: the render is succesful if the one of the dimensions of the input image is increased to 4097.

Replacing CILanczosScaleTransform with CIAffineTransform (lower quality) or resizing the image with CG are possible workarounds for the provided sample code.

关于ios - 当 scaleKey 大于某个值时,Lanczos 比例不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26063040/

相关文章:

iphone - 使用丢失的 EXIF 标签更正存储在文档中的 UIImage 的方向

ios - Swift 表格 View 单元格不显示部分背景图像

ios - 在两个 View Controller Swift IOS 之间传递数据

date - 在 iOS 7 中输入类型 = 日期

ios - AVCaptureSession didReceiveMemoryWarning

iphone - 清除部分 UIImage

ios - objective-C/iOS : PopOver

iphone - kSecReturnPersistentRef 有什么作用?

objective-c - 根据文本大小更改 UITextView 的高度 - ios7

ios - CCMenu 在 iOS 7 下错位