Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 应用具有50%alpha的CIHardLightBlendMode_Ios_Swift_Alpha_Core Image_Cifilter - Fatal编程技术网

Ios 应用具有50%alpha的CIHardLightBlendMode

Ios 应用具有50%alpha的CIHardLightBlendMode,ios,swift,alpha,core-image,cifilter,Ios,Swift,Alpha,Core Image,Cifilter,我正在将一个CIImage与一个斑点灰色(胶片颗粒状)文件混合: 我怎样才能只应用50%的效果 我试图找到一种方法来设置grainImage的alpha值,以查看其效果。但我还没弄明白 有什么想法吗?这不是很直观,但是您可以使用CIColorMatrix过滤器来操作图像的alpha值: let colorMatrixFilter = CIFilter(name: "CIColorMatrix")! colorMatrixFilter.setValue(grainImage,

我正在将一个CIImage与一个斑点灰色(胶片颗粒状)文件混合:

我怎样才能只应用50%的效果

我试图找到一种方法来设置
grainImage
的alpha值,以查看其效果。但我还没弄明白


有什么想法吗?

这不是很直观,但是您可以使用
CIColorMatrix
过滤器来操作图像的alpha值:

let colorMatrixFilter = CIFilter(name: "CIColorMatrix")!
colorMatrixFilter.setValue(grainImage, forKey: kCIInputImageKey)
colorMatrixFilter.setValue(CIVector(x: 0.0, y: 0.0, z: 0.0, w: 0.5), forKey: "inputAVector") // where 0.5 is the factor applied to alpha
let transparentGainImage = colorMatrixFilter.outputImage!

今天学到了一些新东西。谢谢你,弗兰克!
let colorMatrixFilter = CIFilter(name: "CIColorMatrix")!
colorMatrixFilter.setValue(grainImage, forKey: kCIInputImageKey)
colorMatrixFilter.setValue(CIVector(x: 0.0, y: 0.0, z: 0.0, w: 0.5), forKey: "inputAVector") // where 0.5 is the factor applied to alpha
let transparentGainImage = colorMatrixFilter.outputImage!