错误代码:

    if (iOS9)
    {
        CGImageRef cgImage = [[CIContext new] createCGImage:outputImage fromRect:outputImage.extent];
        imageTwo = [UIImage imageWithCGImage:cgImage];
    }
    else
    {
        CGImageRef cgImage = [[CIContext new] createCGImage:outputImage fromRect:outputImage.extent];
        CGContextRef contenxt = UIGraphicsGetCurrentContext();
        CGContextDrawImage(contenxt, outputImage.extent, cgImage);

        imageTwo = [UIImage imageWithCIImage:outputImage];
    }
    

错误原因:

1.没有有效的获得上下文

2.没有通过CGImage获得UIImage

处理:

- (CIContext *)context
{
    if (!_context)
    {
        _context = [CIContext contextWithOptions:nil];
    }
    return _context;
}
CIImage * inputImage = [[CIImage alloc] initWithImage:_image];
NSLog(@"%@",inputImage);

[_filter setValue:inputImage forKey:kCIInputImageKey];

CIImage * outputImage = [_filter outputImage];
NSLog(@"%@",outputImage);

CGImageRef cgImage = [self.context createCGImage:outputImage fromRect:outputImage.extent];
NSLog(@"%@",cgImage);

UIImage *imageTwo = [UIImage imageWithCGImage:cgImage];

打印结果:

-- :::60b] <CIPhotoEffectChrome: inputImage=nil>
-- :::60b] <CIImage:    ]>
-- :::60b] <CIImage:    ]>
-- :::60b] <CGImage 0x16ff0cf0>
-- :::60b] <UIImage: 0x16ff0c60>
-- :::60b] 存储图片:YES
-- :::60b] <CGImage 0x16ff0cf0>
-- :::60b] 存储图片:YES
-- :::60b] <CGImage 0x16d184b0>

推荐地址:http://www.cnblogs.com/kenshincui/p/3959951.html

【项目】用CIFilter得到图片没办法保存到沙盒里面,显示是CGImage为空的更多相关文章

  1. 获取保存在沙盒中plist文件的用户的字典信息

    获取保存在沙盒中plist文件的用户的字典信息

  2. cell下载图片的思路 --无沙盒(内存)缓冲

    // // ViewController.m // 06-表格图片下载 // // Created by jerry on 15/9/7. // Copyright (c) 2015年 jerry. ...

  3. IOS把文件保存进沙盒目录

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSS ...

  4. tomcat中实现特定路径下的图片的url访问Tomcat配置图片保存路径,图片不保存在项目路径下

    使用Tomcat作为服务器的时候,如果不配置图片保存路径,将图片保存在项目路径下,那么再次打war包发布项目可能会造成图片的丢失,每次重启前将图片先保存再copy到服务器明显不方便,这时可以配置图片保 ...

  5. 实现app上对csdn的文章查看,以及文章中图片的保存 (制作csdn app 完结篇)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24022165 今天给大家带来CSDN的完结篇,即增加文章的查看和文章中图片的保存 ...

  6. OC 使用CIFilter添加图片

    +(UIImage *)createInviteImgWithUserCodeStr:(NSString *)userCode{ userCode = [NSString stringWithForm ...

  7. 利用POI抽取word中的图片并保存在文件中

    利用POI抽取word中的图片并保存在文件中 poi.apache.org/hwpf/quick-guide.html 1.抽取word doc中的图片 package parse; import j ...

  8. php获取网页中图片并保存到本地

    php获取网页中图片并保存到本地的代码,将网页中图片保存本地文件夹: save_img("http://www.jbxue.com" ?>

  9. php获取网页中图片并保存到本地的代码

    php获取网页中图片并保存到本地的代码,将网页中图片保存本地文件夹: <?php /** * 获取网页中图片,并保存至本地 * by www.jbxue.com */ header(" ...

随机推荐

  1. 转一篇关于Unity的PlayMaker

    这篇文章转自http://va.lent.in/should-you-use-playmaker-in-production/ 此文作者大概深受其苦,吐槽了playmaker的多个蛋疼的地方,这其实说 ...

  2. hwclock 显示或设置CMOS时间

    显示或设置CMOS时间 hwclock [options] 选项 -r               默认选项,读取并打印CMOS时间 -s               将CMOS时间设置为系统时间 - ...

  3. C++的异常处理之一:throw是个一无是处的东西

    看这篇文章学习C++异常处理的基础知识.看完后,还不过瘾,为什么大家在C++代码中都不用Exception?为什么C++11会引入一些变化? 为什么C++ exception handling需要un ...

  4. git 创建别名

    git config --global alias.shortname command 例子如下 git config --global alias.psm 'push origin master' ...

  5. ES6新特性:Proxy代理器

    ES6新特性:Proxy: 要使用的话, 直接在浏览器中执行即可, node和babel目前还没有Proxy的polyfill;,要使用的话,直接在浏览器中运行就好了, 浏览器的兼容性为:chrome ...

  6. JAVA程序员一定知道的优秀第三方库(2016版)

    几乎每个程序员都知道要“避免重复发明轮子”的道理——尽可能使用那些优秀的第三方框架或库,但当真正进入开发时,我却经常发现他们有时并不知道那些轮子在哪里.最近,我在业余时间带几个年轻的程序员一起做了一个 ...

  7. 成为JavaGC专家(1)—深入浅出Java垃圾回收机制

    转载自:http://www.importnew.com/1993.html 对于Java开发人员来说,了解垃圾回收机制(GC)有哪些好处呢?首先可以满足作为一名软件工程师的求知欲,其次,深入了解GC ...

  8. python3 报错集合

    1.格式 message = "GET / HTTP/1.1\r\n\r\n" s.sendall(message) TypeError: 'str' does not suppo ...

  9. 【BZOJ-1367】sequence 可并堆+中位数

    1367: [Baltic2004]sequence Time Limit: 20 Sec  Memory Limit: 64 MBSubmit: 932  Solved: 348[Submit][S ...

  10. linux中/和/root(~) 和 /home

    winodws是森林型目录结构,它有很多根,如C.D.E.F等都是它的根目录,然后在其实创建子目录linux是树型目录结构,它只有一个根就是/目录,然后在/目录在有子目录如/root./home./e ...