【发布时间】:2012-01-23 20:05:22
【问题描述】:
我正在尝试使用 CISourceOverCompositing 过滤器,但我遇到了一些问题。
这是相关代码。 mask 是 UIImage,images 是 UIImage 的数组
ci_mask = [[CIImage alloc] initWithCGImage: mask.CGImage];
ctx = [CIContext contextWithOptions: nil];
compo = [CIFilter filterWithName: @"CISourceOverCompositing"];
for(int i = 0; i < images.count; i++) {
UIImage *image = [images objectAtIndex: i];
ci_base = [[CIImage alloc] initWithCGImage: image.CGImage];
[compo setDefaults];
[compo setValue: ci_mask forKey: @"inputImage"];
[compo setValue: ci_base forKey: @"inputBackgroundImage"];
result = compo.outputImage;
CGImageDestinationAddImage(
dst_ref,
[ctx createCGImage: result fromRect:result.extent],
frame_props
);
}
mask 包含一个 alpha 通道,它在模拟器中正确应用但在设备上没有。输出仅按原样显示蒙版,而不使用 Alpha 通道来混合图像。
使用 CoreGraphics API 的几乎相同的代码工作正常(但我不能应用其他 CIFilters)
我可能会尝试使用CIBlendWithMask,但随后我将不得不提取掩码并增加复杂性...
【问题讨论】:
标签: iphone ios ios5 core-image