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