iOS UIImage being rotated when after going through CIFilter

こ雲淡風輕ζ 提交于 2019-12-07 12:13:02

问题


I'm working with filtering images that I'm taking with the camera. I pass the image I get from the camera through the below method. Which I have the returned UIImage sent to a UIImageView. For some reason when it passes through this method the image is getting rotated. What am I doing wrong?

    - (UIImage *) applyFilterToImage:(UIImage *)image withFilter:(NSString *)filterName {

    beginImage = [[[CIImage alloc] initWithImage:image] autorelease];
    context = [CIContext contextWithOptions:nil];
    filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues:kCIInputImageKey, beginImage, @"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
    outputImage = [filter outputImage];

    CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
    UIImage *newImg = [UIImage imageWithCGImage:cgimg scale:1.0 orientation:UIImageOrientationUp];
    CGImageRelease(cgimg);

    return scaleAndRotateImage(newImg);
}

来源:https://stackoverflow.com/questions/9913939/ios-uiimage-being-rotated-when-after-going-through-cifilter

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