最近项目中,需要对图片进行各种操作。

使用CGBitmapContextCreate 创建位图上下文。

CG_EXTERN CGContextRefCGBitmapContextCreate(void*data,size_twidth,

size_theight,size_tbitsPerComponent,size_tbytesPerRow,

CGColorSpaceRefspace,CGBitmapInfobitmapInfo)

CG_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_2_0);

介绍:

当你调用这个函数的时候,Quartz创建一个位图绘制环境,也就是位图上下文。当你向上下文中绘制信息时,Quartz把你要绘制的信息作为位图数据绘制到指定的内存块。一个新的位图上下文的像素格式由三个参数决定:每个组件的位数,颜色空间,alpha选项。alpha值决定了绘制像素的透明性。

参数:

data :需要渲染的内存地址,大小至少需要bytesPerRow*height(`data',ifnon-NULL,pointstoablock ofmemoryatleast`bytesPerRow*height'bytes.)

width:像素的宽度(pixels wide)

height:像素的高度(pixels height)

bitsPerComponent:内存中像素的每个组件的位数.一般设为8( The number of bits for each component of a pixelis specified by  `bitsPer Component'.)

bytesPerRow:位图的每一行在内存所占的bytes(Each row of the bitmap consists of`bytes Per Row' bytes)

space:bitmap上下文的空间。

bitmapInfo:枚举值,位图信息,是否包含alpha通道

typedef CF_OPTIONS(uint32_t, CGBitmapInfo)

{

kCGBitmapAlphaInfoMask = 0x1F,

kCGBitmapFloatComponents = (1 << 8),

kCGBitmapByteOrderMask = 0x7000,

kCGBitmapByteOrderDefault = (0 << 12),

kCGBitmapByteOrder16Little = (1 << 12),

kCGBitmapByteOrder32Little = (2 << 12),

kCGBitmapByteOrder16Big = (3 << 12),

kCGBitmapByteOrder32Big = (4 << 12)

} CF_ENUM_AVAILABLE(10_4, 2_0);

最新文章

  1. npm 发布到远程资源库
  2. 体验VS2015 Update 2 的 Android 和 Python
  3. Alpha阶段第七次Scrum Meeting
  4. [Maven] - Eclipse &quot;maven compiler plugin&quot; 冲突解决
  5. js null和undefined
  6. Virtualbox: Shared directory- “unknown filesystem type vboxsf”
  7. 关于JS加载的问题
  8. Python高手之路【九】python基础之迭代器与生成器
  9. 基于stm32的can总线彻底研究
  10. ●POJ 1741 Tree
  11. L2-006 树的遍历 (25 分) (根据后序遍历与中序遍历建二叉树)
  12. 第八周 ip通信基础回顾
  13. Node.js中读取文件后用Json.parse方法报错解决方案
  14. CDN拾遗
  15. redis key的过期时间
  16. idea操作快捷键
  17. shuoj 418 丢史蒂芬妮(素数筛+sg函数)
  18. ORM创建 脚本运行
  19. Spring Security构建Rest服务-0400-使用切片拦截rest服务
  20. Python爬虫教程-06-爬虫实现百度翻译(requests)

热门文章

  1. CodeForces 8D Two Friends 判断三个圆相交
  2. POJ 3469 最小割 Dual Core CPU
  3. luogu2761 软件补丁问题
  4. 快速排序-php代码实现
  5. 九度oj 题目1494:Dota
  6. hibernate框架的搭建与简单实现增删改
  7. 【bzoj3751】[NOIP2014]解方程 数论
  8. Multiset ------ 多重集合
  9. POJ3349 Snowflake Snow Snowflakes 【哈希表】
  10. restful的nginx配置方法