Fix some CIFilter implementation
This commit is contained in:
parent
3c89a092cd
commit
7892f4ca20
|
@ -659,7 +659,9 @@ static NSString * _Nullable SDGetCIFilterNameFromBlendMode(CGBlendMode blendMode
|
||||||
} else {
|
} else {
|
||||||
clearColor = [[CIColor alloc] initWithColor:UIColor.clearColor];
|
clearColor = [[CIColor alloc] initWithColor:UIColor.clearColor];
|
||||||
}
|
}
|
||||||
ciImage = [CIImage imageWithColor:clearColor];
|
colorImage = [CIImage imageWithColor:clearColor];
|
||||||
|
colorImage = [colorImage imageByCroppingToRect:ciImage.extent];
|
||||||
|
ciImage = colorImage;
|
||||||
} else if (blendMode == kCGBlendModeCopy) {
|
} else if (blendMode == kCGBlendModeCopy) {
|
||||||
// R = S
|
// R = S
|
||||||
ciImage = colorImage;
|
ciImage = colorImage;
|
||||||
|
@ -675,12 +677,14 @@ static NSString * _Nullable SDGetCIFilterNameFromBlendMode(CGBlendMode blendMode
|
||||||
} else if (blendMode == kCGBlendModePlusDarker) {
|
} else if (blendMode == kCGBlendModePlusDarker) {
|
||||||
// R = MAX(0, (1 - D) + (1 - S))
|
// R = MAX(0, (1 - D) + (1 - S))
|
||||||
// (1 - D)
|
// (1 - D)
|
||||||
CIFilter *filter1 = [CIFilter filterWithName:@"CIColorInvert"];
|
CIFilter *filter1 = [CIFilter filterWithName:@"CIColorControls"];
|
||||||
[filter1 setValue:ciImage forKey:kCIInputImageKey];
|
[filter1 setValue:ciImage forKey:kCIInputImageKey];
|
||||||
|
[filter1 setValue:@(-0.5) forKey:kCIInputBrightnessKey];
|
||||||
ciImage = filter1.outputImage;
|
ciImage = filter1.outputImage;
|
||||||
// (1 - S)
|
// (1 - S)
|
||||||
CIFilter *filter2 = [CIFilter filterWithName:@"CIColorInvert"];
|
CIFilter *filter2 = [CIFilter filterWithName:@"CIColorControls"];
|
||||||
[filter2 setValue:colorImage forKey:kCIInputImageKey];
|
[filter2 setValue:colorImage forKey:kCIInputImageKey];
|
||||||
|
[filter2 setValue:@(-0.5) forKey:kCIInputBrightnessKey];
|
||||||
colorImage = filter2.outputImage;
|
colorImage = filter2.outputImage;
|
||||||
// +
|
// +
|
||||||
CIFilter *filter = [CIFilter filterWithName:@"CIAdditionCompositing"];
|
CIFilter *filter = [CIFilter filterWithName:@"CIAdditionCompositing"];
|
||||||
|
|
|
@ -243,7 +243,7 @@ static void SDAssertCGImageFirstComponentWhite(CGImageRef image, OSType pixelTyp
|
||||||
UIColor *topCenterColor = [tintedImage sd_colorAtPoint:CGPointMake(150, 20)];
|
UIColor *topCenterColor = [tintedImage sd_colorAtPoint:CGPointMake(150, 20)];
|
||||||
expect([topCenterColor.sd_hexString isEqualToString:[UIColor blackColor].sd_hexString]).beTruthy();
|
expect([topCenterColor.sd_hexString isEqualToString:[UIColor blackColor].sd_hexString]).beTruthy();
|
||||||
|
|
||||||
UIImage *tintedSourceInImage = [testImage sd_tintedImageWithColor:tintColor blendMode:kCGBlendModeSourceOut];
|
UIImage *tintedSourceInImage = [testImage sd_tintedImageWithColor:tintColor blendMode:kCGBlendModeSourceIn];
|
||||||
centerColor = [tintedSourceInImage sd_colorAtPoint:CGPointMake(150, 150)];
|
centerColor = [tintedSourceInImage sd_colorAtPoint:CGPointMake(150, 150)];
|
||||||
expect([centerColor.sd_hexString isEqualToString:[UIColor blackColor].sd_hexString]).beTruthy();
|
expect([centerColor.sd_hexString isEqualToString:[UIColor blackColor].sd_hexString]).beTruthy();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue