Horizontal Flip of a frame in Objective-C

时间秒杀一切 提交于 2019-12-04 10:36:50

I'm not sure if this is the problem, but in your first code snippet you are setting two different values for the same key (you set inputTransform twice), I think the first one should be inputImage instead. Try the following instead:

CIImage *resultImage = image;
CIFilter *flipFilter = [CIFilter filterWithName:@"CIAffineTransform"];
[flipFilter setValue:resultImage forKey:@"inputImage"];

NSAffineTransform* flipTransform = [NSAffineTransform transform];
[flipTransform scaleXBy:-1.0 yBy:1.0]; //horizontal flip
[flipFilter setValue:flipTransform forKey:@"inputTransform"];

resultImage = [flipFilter valueForKey:@"outputImage"];

Also, you may need to translate the X axis by the width of the image

[flipTransform translateXBy:... yBy:0];
CIImage *cimage = [[CIImage alloc] initWithImage:image];

You are not Allocating CIImage Object . Try This code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!