gpt4 book ai didi

ios - 使用 CiGaussianBlur 模糊图像的 UISlider 也旋转图像

转载 作者:行者123 更新时间:2023-11-29 10:42:44 27 4
gpt4 key购买 nike

我有一个范围从 0 到 30 的 UISlider。

不幸的是,当我使用 UISlider 时,图像开始变得模糊,但它也在旋转。

代码如下:

-(IBAction)slider:(UISlider *)sender
{
float slideValue = [sender value];

CIImage *beginImage = [[CIImage alloc] initWithImage:image];
CIContext *context = [CIContext contextWithOptions:nil];

CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur" keysAndValues:kCIInputImageKey, beginImage, @"inputRadius", [NSNumber numberWithFloat:slideValue], nil];
CIImage *outputImage = [filter valueForKey:kCIOutputImageKey];

CGImageRef cgimg = [context createCGImage:outputImage fromRect:[beginImage extent]];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];

[imageView setImage:newImg];
CGImageRelease(cgimg);
}

问题出在哪里?

提前致谢。

最佳答案

问题是这一行:

UIImage *newImg = [UIImage imageWithCGImage:cgimg];

这也太简单了吧。调用 [UIImage imageWithCGImage:cgimg scale:originalScale orientation:originalOrientation];(您需要为这些提供正确的值)。

关于ios - 使用 CiGaussianBlur 模糊图像的 UISlider 也旋转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23713390/

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