我正在嘗試使用CISourceOverCompositing
過濾器,但我正在碰壁。CISourceOverCompositing在設備和模擬器上產生不同的結果
這是相關代碼。掩模是UIImage
和圖像是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通道來混合圖像。
幾乎相同的代碼使用CoreGraphics的API工作正常(但我不能申請其他CIFilters)
我可能會嘗試使用CIBlendWithMask
但後來我不得不提取面罩和增加複雜性。 ..