how to perform Bump Distortion in ios 5.0?

2020-03-31 07:25发布

问题:

i need to perform Bump Distortion in ios 5.0... my xcode doesn't show any error and also i am not get any output ... while trace and print the Bump filter instance it prints the null value...

any idea about that...

some of the post shows that was not work in ios 5.0, any other way is there to perform the Bump Distortion...

Thanks in advance....

Regards,

Spynet

My code...

context = [CIContext contextWithOptions:nil];
     CIFilter *bumpDistortion = [CIFilter filterWithName:@"CIBumpDistortion"];
     [bumpDistortion setValue:ciimage forKey:kCIInputImageKey];
     [bumpDistortion setValue:[CIVector vectorWithX:200 Y:150] forKey:@"inputCenter"];
     [bumpDistortion setValue:[NSNumber numberWithFloat:100] forKey:@"inputRadius"];
     [bumpDistortion setValue:[NSNumber numberWithFloat:3.0] forKey:@"inputScale"];

    CIImage *imageOutput = [bumpDistortion outputImage];

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

    [self.imageView setImage:newImg];

回答1:

As omz points out, this particular Core Image filter is missing as of iOS 5.1.

However, you can easily do this using my GPUImage framework and the GPUImageBulgeDistortionFilter:

For processing a UIImage, and getting a UIImage result, you'd use code like the following:

UIImage *inputImage = [UIImage imageNamed:@"test.jpg"];
GPUImageBulgeDistortionFilter *stillImageFilter = [[GPUImageBulgeDistortionFilter alloc] init];
UIImage *quickFilteredImage = [stillImageFilter imageByFilteringImage:inputImage];

You can also do this on live video or prerecorded movies in realtime.

I show a few other distortions you can perform with this framework in this answer.



回答2:

Calling [CIFilter filterNamesInCategory:kCICategoryDistortionEffect] will show you that distortion filters (such as CIBumpDistortion) aren't available at all on iOS.

You can use the same method with kCICategoryBuiltIn to get a list of all filters that are available.