CGBitmapInfo
Component information for a bitmap image.
位图的组成部分信息
Declaration
SWIFT
struct CGBitmapInfo : OptionSetType {
init(rawValue rawValue: UInt32)
static var AlphaInfoMask: CGBitmapInfo { get }
static var FloatInfoMask: CGBitmapInfo { get }
static var FloatComponents: CGBitmapInfo { get }
static var ByteOrderMask: CGBitmapInfo { get }
static var ByteOrderDefault: CGBitmapInfo { get }
static var ByteOrder16Little: CGBitmapInfo { get }
static var ByteOrder32Little: CGBitmapInfo { get }
static var ByteOrder16Big: CGBitmapInfo { get }
static var ByteOrder32Big: CGBitmapInfo { get }
}
OBJECTIVE-C
enum {
kCGBitmapAlphaInfoMask = 0x1F,
kCGBitmapFloatComponents = (1 << 8),
kCGBitmapByteOrderMask = 0x7000,
kCGBitmapByteOrderDefault = (0 << 12),
kCGBitmapByteOrder16Little = (1 << 12),
kCGBitmapByteOrder32Little = (2 << 12),
kCGBitmapByteOrder16Big = (3 << 12),
kCGBitmapByteOrder32Big = (4 << 12)
};
typedef uint32_t CGBitmapInfo;
Constants
-kCGBitmapAlphaInfoMask
The alpha information mask. Use this to extract alpha information that specifies whether a bitmap contains an alpha channel and how the alpha channel is generated.
Aplha通道信息遮罩。用这个值来提取alpha信息。这个值明确了位图是否包含了alpha通道和alpha通道是如何生成的
Available in iOS 2.0 and later.
-kCGBitmapFloatComponents
The components of a bitmap are floating-point values.
Available in iOS 2.0 and later.
-kCGBitmapByteOrderMask
The byte ordering of pixel formats.
Available in iOS 2.0 and later.
-kCGBitmapByteOrderDefault
The default byte order.
默认的字节序
Available in iOS 2.0 and later.
-kCGBitmapByteOrder16Little
16-bit, little endian format.
16位小字节序格式
Available in iOS 2.0 and later.
-kCGBitmapByteOrder32Little
32-bit, little endian format.
32位小字节序格式
Available in iOS 2.0 and later.
-kCGBitmapByteOrder16Big
16-bit, big endian format.
16位大字节序格式
Available in iOS 2.0 and later.
-kCGBitmapByteOrder32Big
32-bit, big endian format.
32位大字节序格式
Available in iOS 2.0 and later.
Discussion
Applications that store pixel data in memory using ARGB format must take care in how they read data. If the code is not written correctly, it’s possible to misread the data which leads to colors or alpha that appear wrong. The Quartz byte order constants specify the byte ordering of pixel formats. To specify byte ordering to Quartz use a bitwise OR operator to combine the appropriate constant with the bitmapInfo parameter.
使用ARGB格式存在内存中储像素数据的应用一定要注意读取数据的方式。如果代码写错了,有可能会误读数据从而导致了错误的颜色或alpha值。Quartz字节序常量明确了像素格式的字节序。使用 按位或运算符 把bitmapInfo 参数和合适的常量结合在一起给Quartz明确字节序。
Import Statement
OBJECTIVE-C
@import CoreGraphics;
SWIFT
import CoreGraphics
Availability
Available in iOS 2.0 and later.