gpt4 book ai didi

iOS8 我可以使用 CIFilter 为 UIImage 的色调/饱和度/亮度设置动画吗?

转载 作者:行者123 更新时间:2023-12-01 15:51:37 26 4
gpt4 key购买 nike

我正在查看 an Apple example that uses core image filters to adjust Hue/saturation/brightness的图像。在这种情况下,输入图像的属性已调整,并且作为过滤操作的结果返回另一个图像。我很感兴趣这种过渡是否可以动画化(逐步过渡)。

有没有办法让我以编程方式为颜色缓慢淡入的黑白图像制作动画?

我检查了 Apple view programming guidelines ,但看不到任何关于动画图像或颜色的信息。

- (void)hueChanged:(id)sender
{
CGFloat hue = [hueSlider value];
CGFloat saturation = [saturationSlider value];
CGFloat brightness = [brightnessSlider value];

// Update labels

[hueLabel setText:[NSString stringWithFormat:NSLocalizedString(@"Hue: %f", @"Hue label format."), hue]];
[saturationLabel setText:[NSString stringWithFormat:NSLocalizedString(@"Saturation: %f",

@"Saturation label format."), saturation]];
[brightnessLabel setText:[NSString stringWithFormat:NSLocalizedString(@"Brightness: %f", @"Brightness label format."), brightness]];

// Apply effects to image


dispatch_async(processingQueue, ^{
if (!self.colorControlsFilter) {
self.colorControlsFilter = [CIFilter filterWithName:@"CIColorControls"];
}
[self.colorControlsFilter setValue:self.baseCIImage forKey:kCIInputImageKey];
[self.colorControlsFilter setValue:@(saturation) forKey:@"inputSaturation"];
[self.colorControlsFilter setValue:@(brightness) forKey:@"inputBrightness"];

CIImage *coreImageOutputImage = [self.colorControlsFilter valueForKey:kCIOutputImageKey];

if (!self.hueAdjustFilter) {
self.hueAdjustFilter = [CIFilter filterWithName:@"CIHueAdjust"];
}
[self.hueAdjustFilter setValue:coreImageOutputImage forKey:kCIInputImageKey];
[self.hueAdjustFilter setValue:@(hue) forKey:@"inputAngle"];

coreImageOutputImage = [self.hueAdjustFilter valueForKey:kCIOutputImageKey];

CGRect rect = CGRectMake(0,0,self.image.size.width,self.image.size.height);
CGImageRef cgImage = [self.context createCGImage:coreImageOutputImage fromRect:rect];
UIImage *image = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);

dispatch_async(dispatch_get_main_queue(), ^{
[imageView setImage:image];
});
});

// imageView.center = self.view.center;
// imageView.frame = self.view.frame;

}

最佳答案

对于缓慢淡出的动画,您可以使用 IOS 中的核心动画

theView.alpha = 0;
[UIView animateWithDuration:1.0
animations:^{

//Apply effects to image here

theView.center = midCenter;
theView.alpha = 1;


}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0
animations:^{
//Apply effects to image here
}
completion:^(BOOL finished){

}];
}];

关于iOS8 我可以使用 CIFilter 为 UIImage 的色调/饱和度/亮度设置动画吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25331788/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com