gpt4 book ai didi

ios - CIGaussianBlur 有时会改变 imageOrientation

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:07:01 24 4
gpt4 key购买 nike

在我的 iOS 应用程序中,我想在 UIImage 上应用滤镜 CIGaussianBlur,当它获得具有较大高度的图像时,它会旋转图像

   CIContext *context = [CIContext contextWithOptions:nil];
CIImage *inputImage = [[CIImage alloc] initWithImage:image]; //get image for blur

CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[blurFilter setDefaults];
[blurFilter setValue:inputImage forKey:@"inputImage"];
CGFloat blurLevel = 0.0f; // Set blur level
[blurFilter setValue:[NSNumber numberWithFloat:blurLevel] forKey:@"inputRadius"];

// set value for blur level
CIImage *outputImage = [blurFilter valueForKey:@"outputImage"];
CGRect rect = inputImage.extent; // Create Rect
rect.origin.x += blurLevel; // and set custom params
rect.origin.y += blurLevel; //
rect.size.height -= blurLevel*2.0f; //
rect.size.width -= blurLevel*2.0f; //
CGImageRef cgImage = [context createCGImage:outputImage fromRect:rect];

// Then apply new rect
UIImageOrientation originalOrientation = _imageView.image.imageOrientation;
CGFloat originalScale = _imageView.image.scale;

UIImage *fixedImage=[UIImage imageWithCGImage:cgImage scale:originalScale orientation:originalOrientation] ; //output of CIGaussianBlur

最佳答案

它对我有用。

_imageView.image=image;

UIImageOrientation originalOrientation = _imageView.image.imageOrientation;

CGFloat originalScale = _imageView.image.scale;

UIImage *fixedImage=[UIImage imageWithCGImage:cgImage scale:originalScale orientation:originalOrientation] ;

关于ios - CIGaussianBlur 有时会改变 imageOrientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21185207/

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