iOS核心图像混合模式与Photoshop混合模式有何不同?

时间:2013-03-09 10:13:31

标签: ios objective-c photoshop core-image cifilter

我正在使用CIFilter和CIHueBlendMode来混合图像(前景)和红色图层(背景)

我在Photoshop CS6中使用Hue Blend Mode完成了相同的操作(复制了前景图像并使用相同的红色填充背景图层)

不幸的是结果非常不同: enter image description here (同样适用于将CIColorBlendMode,CIDifferenceBlendMode和CISaturationBlendMode与其Photoshop对应物进行比较)

我的问题是:是我吗?我在这里做错了吗?或者Core Image Blend Modes和Photoshop Blend Modes完全不同?

// Blending the input image with a red image  
CIFilter* composite = [CIFilter filterWithName:@"CIHueBlendMode"];
[composite setValue:inputImage forKey:@"inputImage"];
[composite setValue:redImage forKey:@"inputBackgroundImage"];

CIImage *outputImage = [composite outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
imageView.image = [UIImage imageWithCGImage:cgimg];
CGImageRelease(cgimg);

// This is how I create the red image:       
- (CIImage *)imageWithColor:(UIColor *)color inRect:(CGRect)rect
{
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef _context = UIGraphicsGetCurrentContext(); 
    CGContextSetFillColorWithColor(_context, [color CGColor]);
    CGContextFillRect(_context, rect); 
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return [[CIImage alloc] initWithCGImage:image.CGImage options:nil];
}

0 个答案:

没有答案