分类: iOS开发2013-11-28 15:55 745人阅读 评论(0) 收藏 举报

在使用xcode5 sdk iOS7环境,创建图形上下文进行图形绘制,合并,裁剪,特效处理等时避免不了使用如下方法创建位图:

在 iOS7以前,是使用如下方法创建的:

CG_EXTERN CGContextRef CGBitmapContextCreate(void *data, size_t width,

size_t height, size_t bitsPerComponent, size_t bytesPerRow,

CGColorSpaceRef space,CGImageAlphaInfo bitmapInfo)

注意最后一个参数类型是 CGImageAlphaInfo 枚举类型中的kCGImageAlphaPremultipliedLast值。其整型值为1。

但是在iOS7版本中,这个最后的参会类型发生了变化。看一下定义:

CGContextRef CGBitmapContextCreate(void *data,size_t width,

size_t height,size_t bitsPerComponent, size_t bytesPerRow,

CGColorSpaceRef space,CGBitmapInfo bitmapInfo)

很明显最后一个参数由CGImageAlphaInfo 变化为 CGBitmapInfo,看一下这个类型的定义

从头到尾没有发现值为1的枚举量值。故在使用的时候会出现如下警告:

Implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGBitmapInfo' (aka 'enum CGBitmapInfo')

意思很明显不过,类型不匹配非法。

以下给出解决方法:

第一种方法,定义宏:

这样就会直接映射出一个值为1的宏,原有方法不用改变。

第二种方法:原理和第一个一样,目的 还是为了生产出一个为1的值,直接修改代码。

其实所有的做法,不外乎为了使这里的值为1,类型匹配。你也直接可以传1,不用麻烦的各种写代码。也可以直接进行类型强制转换,这个你随便。只是每个人的习惯不一样,故,如何解决,自己参考决定 。

Implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGB的更多相关文章

  1. Implicit conversion from enumeration type 'enum CGImageAlphaInfo' to different enumeration type 'CGBitmapinfo' (aka) 'enum CGBitmapInfo')

    The constants for specifying the alpha channel information are declared with the CGImageAlphaInfo ty ...

  2. 解决spring mvc 上传报错,Field [] isn't an enum value,Failed to convert value of type 'java.lang.String[]' to required type '

    没有选择附件,但是点击上传按钮的时候会报错. 之前不选择文件,直接上传空文件是可以的,后来不知道改了什么就不行了. 错误信息: -- :: [http--] TRACE org.springframe ...

  3. solidity智能合约implicit conversion异常

    问题场景 在使用^0.5.10版本的solidity时,如果使用this关键字会出现以下问题. 代码: require(tokenContract.balanceOf(this) >= _num ...

  4. Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx': no matching editors or conversion strategy found

    今天在完成项目的时候遇到了下面的异常信息: 04-Aug-2014 15:49:27.894 SEVERE [http-apr-8080-exec-5] org.apache.catalina.cor ...

  5. (转)怎么去掉Xcode工程中的某种类型的警告 Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int32

    问题描述  在我们的项目中,通常使用了大量的第三方代码,这些代码可能很复杂,我们不敢改动他们,可是作者已经停止更新了,当sdk升级或者是编译器升级后,这些遗留的代码可能会出现许许多多的警告,那么我们有 ...

  6. Type mismatch: cannot convert from Enumeration<String> to Enumeration<Object>

    完整的错误信息: Description Resource Path Location TypeType mismatch: cannot convert from Enumeration<St ...

  7. 怎么去掉Xcode工程中的某种类型的警告 Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int32

    unsigned long numComponents = CGColorGetNumberOfComponents([[UIColor blackColor] CGColor]); 2014年12月 ...

  8. 怎么去掉Xcodeproject中的某种类型的警告 Implicit conversion loses integer precision: &#39;NSInteger&#39; (aka &#39;long&#39;) to &#39;int32

    问题描写叙述  在我们的项目中,通常使用了大量的第三方代码,这些代码可能非常复杂,我们不敢修改他们,但是作者已经停止更新了,当sdk升级或者是编译器升级后,这些遗留的代码可能会出现许很多多的警告,那么 ...

  9. Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFa ...

随机推荐

  1. sublimelinter-jshinter

    --- ocalhost:~ nihao$ sudo npm install jshint -gPassword:/usr/local/bin/jshint -> /usr/local/lib/ ...

  2. Codeforces10D–LCIS(区间DP)

    题目大意 给定两个序列,要求你求出最长公共上升子序列 题解 LIS和LCS的合体,YY好久没YY出方程,看了网友的题解,主要是参考aikilis的,直接搬过来好了 经典的动态规划优化. 用opt[i] ...

  3. 新浪微博、腾讯微博、QQ空间、人人网、豆瓣 一键分享API

    新浪微博: http://service.weibo.com/share/share.php?url= count=表示是否显示当前页面被分享数量(1显示)(可选,允许为空) & url=将页 ...

  4. autoSvn

    #!/bin/bash    dir="/svndata" name="puppet" user="test" passwd="t ...

  5. nyoj 678 最小K个数之和

    最小K个数之和 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 输入n个整数,输出其中最小的K个数之和.例如输入4,5,1,1,6,2,7,3,3这9个数字,当k=4 ...

  6. 如何查看tomcat是32位还是64位

    原文地址:http://www.cnblogs.com/andysd/p/3940976.html

  7. 关于.net的一些基础知识(二)

    索引器是什么?有什么作用?索引器允许类的实例以访问数组的形式来访问对象里面的属性.如我们经常可以看到类似于dr[“name”]=”test”,或者说以config[“connectString”]来获 ...

  8. SQLite数据库如何存储和读取二进制数据

    SQLite数据库如何存储和读取二进制数据 1. 存储二进制数据 SQLite提供的绑定二进制参数接口函数为: int sqlite3_bind_blob(sqlite3_stmt*, int, co ...

  9. 设置 Linux 文件和文件夹权限的方法

    1.字符表示法 类型 操作 权限 u + r g - w o = x a 类型代表改动权限的对象,u表示文件的用户.g表示文件全部者的群组,o表示非用户组用户.a表示ugo 操作 + 表示添加权限,- ...

  10. QTP下载链接

    QTP下载链接 QTP官网下载:http://www8.hp.com/us/en/software-solutions/software.html?compURI=1172957#.UNMOQ2_FW ...