zoukankan      html  css  js  c++  java
  • 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);

     

  • 相关阅读:
    OC-KVO简介
    注册审核
    应用权限
    关于函数执行的一点知识
    设置权限
    文件操作实例:文件管理器(网页版)
    文件操作
    正则表达式
    全局变量和递归
    案例:简单留言板
  • 原文地址:https://www.cnblogs.com/moyunmo/p/3658415.html
Copyright © 2011-2022 走看看