画像 (前景) と赤いレイヤー (背景) をブレンドするために、CIFilter と CIHueBlendMode を使用しています。
色相ブレンドモードを使用してPhotoshop CS6でまったく同じことを行っています(前景画像をコピーし、同じ赤を使用して背景レイヤーを塗りつぶしました)
残念ながら、結果は大きく異なります
(CIColorBlendMode、CIDifferenceBlendMode、CISaturationBlendMode を Photoshop の対応するものと比較する場合も同様です)。
私の質問は:それは私ですか?ここで何か間違ったことをしていますか?それとも、コア イメージ ブレンド モードと Photoshop ブレンド モードはまったく別のものですか?
// 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];
}