【项目】用CIFilter得到图片没办法保存到沙盒里面,显示是CGImage为空
错误代码:
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为空的更多相关文章
- 获取保存在沙盒中plist文件的用户的字典信息
获取保存在沙盒中plist文件的用户的字典信息
- cell下载图片的思路 --无沙盒(内存)缓冲
// // ViewController.m // 06-表格图片下载 // // Created by jerry on 15/9/7. // Copyright (c) 2015年 jerry. ...
- IOS把文件保存进沙盒目录
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSS ...
- tomcat中实现特定路径下的图片的url访问Tomcat配置图片保存路径,图片不保存在项目路径下
使用Tomcat作为服务器的时候,如果不配置图片保存路径,将图片保存在项目路径下,那么再次打war包发布项目可能会造成图片的丢失,每次重启前将图片先保存再copy到服务器明显不方便,这时可以配置图片保 ...
- 实现app上对csdn的文章查看,以及文章中图片的保存 (制作csdn app 完结篇)
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24022165 今天给大家带来CSDN的完结篇,即增加文章的查看和文章中图片的保存 ...
- OC 使用CIFilter添加图片
+(UIImage *)createInviteImgWithUserCodeStr:(NSString *)userCode{ userCode = [NSString stringWithForm ...
- 利用POI抽取word中的图片并保存在文件中
利用POI抽取word中的图片并保存在文件中 poi.apache.org/hwpf/quick-guide.html 1.抽取word doc中的图片 package parse; import j ...
- php获取网页中图片并保存到本地
php获取网页中图片并保存到本地的代码,将网页中图片保存本地文件夹: save_img("http://www.jbxue.com" ?>
- php获取网页中图片并保存到本地的代码
php获取网页中图片并保存到本地的代码,将网页中图片保存本地文件夹: <?php /** * 获取网页中图片,并保存至本地 * by www.jbxue.com */ header(" ...
随机推荐
- FFmpeg 1.2 for Android 生成一个动态库
上一篇<FFmpeg 1.2 for Android 编译动态库>里沃特跟大家介绍了如何编译动态库,但当时所生成的动态库总共包含10个so文件,这样要是加载起来会严重影响软件的启动速度,后 ...
- 系统升级日记(2)- 升级到SharePoint Server 2013
最近一段时间在公司忙于将各类系统进行升级,其最主要的目标有两个,一个是将TFS2010升级到TFS2013,另外一个是将SharePoint 2010升级到SharePoint 2013.本记录旨在记 ...
- C# 退出应用程序办法
Application.Exit();//好像只在主线程可以起作用,而且当有线程,或是阻塞方法的情况下,很容易失灵 this.Close();//只是关闭当前窗体. Application.E ...
- Android下的数据储存方式
安卓系统默认提供了一下几种数据储存的方式: Shared Preferences 内部储存 外部储存 SQLite数据库 保存到网络服务器 使用Shared Preferences ...
- linux 下第一个cordova android app
上篇博客写了linux下 cordova + ionic 环境的搭建 , 今天就来做下第一个app的简单讲解吧 首先昨天已经可以通过命令行的方式创建app了.经过今天好一段时间的研究发现使用 ioni ...
- javascript生成GUID的代码
<script type="text/javascript"> var Guid = function(){}; Guid.prototype = { S4:funct ...
- A query was run and no Result Maps were found for the Mapped Statement 'user.insertUser!selectKey'. It's likely that neither a Result Type nor a Result Map was specified.
使用mybatis时出现异常问题: 有如下的错误 Error querying database. Cause: org.apache.ibatis.executor.ExecutorExceptio ...
- android 之 Toast通知的使用
1.默认效果: 代码: Toast.makeText(getApplicationContext(), "默认Toast样式", Toast.LENGTH_SHORT ...
- The resource identified by this request is only capable of generating responses with characteristics
[转]今天在调试springMVC的时候,在将一个对象返回为json串的时候,浏览器中出现异常: The resource identified by this request is only cap ...
- 强连通 HDU 1827
n个点m条边 n个权lcy 要叫这个人的花费 m条边 缩点后 新的图中 入度为0的点要通知 通知强连通分量中权值最小的 #include<stdio.h> #include<alg ...