2013年7月14日 星期日

CGBitmapInfo 資料整理

 CGBitmapInfo 在自行產生圖檔資料時,需要設定此圖檔的相關資料,此時就要用下面參數來設定。

enum CGImageAlphaInfo {
    kCGImageAlphaNone,               /* For example, RGB. */
    kCGImageAlphaPremultipliedLast,  /* For example, premultiplied RGBA */
    kCGImageAlphaPremultipliedFirst, /* For example, premultiplied ARGB */
    kCGImageAlphaLast,               /* For example, non-premultiplied RGBA */
    kCGImageAlphaFirst,              /* For example, non-premultiplied ARGB */
    kCGImageAlphaNoneSkipLast,       /* For example, RBGX. */
    kCGImageAlphaNoneSkipFirst,      /* For example, XRGB. */
    kCGImageAlphaOnly                /* No color data, alpha data only */
};
typedef enum CGImageAlphaInfo CGImageAlphaInfo;

enum {
    kCGBitmapAlphaInfoMask = 0x1F,   //-> CGImageAlphaInfo
    kCGBitmapFloatComponents = (1 << 8),
  
    kCGBitmapByteOrderMask = 0x7000,
    kCGBitmapByteOrderDefault = (0 << 12),
    kCGBitmapByteOrder16Little = (1 << 12),
    kCGBitmapByteOrder32Little = (2 << 12),
    kCGBitmapByteOrder16Big = (3 << 12),
    kCGBitmapByteOrder32Big = (4 << 12)
};
typedef uint32_t CGBitmapInfo; /* Available in MAC OS X 10.4 & later. */
 
參考code
http://stackoverflow.com/questions/6073259/getting-rgb-pixel-data-from-cgimage
 
使用參考例 
CGBitmapContextCreate()的使用方法 

 
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.
Available in OS X v10.4 and later.
Declared in CGImage.h.
kCGBitmapFloatComponents
The components of a bitmap are floating-point values.
Available in OS X v10.4 and later.
Declared in CGImage.h.
kCGBitmapByteOrderMask
The byte ordering of pixel formats.
Available in OS X v10.4 and later.
Declared in CGImage.h.
kCGBitmapByteOrderDefault
The default byte order.
Available in OS X v10.4 and later.
Declared in CGImage.h.
kCGBitmapByteOrder16Little
16-bit, little endian format.
Available in OS X v10.4 and later.
Declared in CGImage.h.
kCGBitmapByteOrder32Little
32-bit, little endian format.
Available in OS X v10.4 and later.
Declared in CGImage.h.
kCGBitmapByteOrder16Big
16-bit, big endian format.
Available in OS X v10.4 and later.
Declared in CGImage.h.
kCGBitmapByteOrder32Big
32-bit, big endian format.
Available in OS X v10.4 and later.
Declared in CGImage.h.
 
 
kCGImageAlphaFirst
The alpha component is stored in the most significant bits of each pixel. For example, non-premultiplied ARGB.
Available in OS X v10.0 and later.
Declared in CGImage.h.
kCGImageAlphaLast
The alpha component is stored in the least significant bits of each pixel. For example, non-premultiplied RGBA.
Available in OS X v10.0 and later.
Declared in CGImage.h.
kCGImageAlphaNone
There is no alpha channel. If the total size of the pixel is greater than the space required for the number of color components in the color space, the least significant bits are ignored. This value is equivalent to kCGImageAlphaNoneSkipLast.
Available in OS X v10.0 and later.
Declared in CGImage.h.
kCGImageAlphaNoneSkipFirst
There is no alpha channel. If the total size of the pixel is greater than the space required for the number of color components in the color space, the most significant bits are ignored.
Available in OS X v10.0 and later.
Declared in CGImage.h.
kCGImageAlphaOnly
There is no color data, only an alpha channel.
Available in OS X v10.3 and later.
Declared in CGImage.h.
kCGImageAlphaNoneSkipLast
There is no alpha channel. If the total size of the pixel is greater than the space required for the number of color components in the color space, the least significant bits are ignored. This value is equivalent to kCGImageAlphaNone.
Available in OS X v10.0 and later.
Declared in CGImage.h.
kCGImageAlphaPremultipliedFirst
The alpha component is stored in the most significant bits of each pixel and the color components have already been multiplied by this alpha value. For example, premultiplied ARGB.
Available in OS X v10.0 and later.
Declared in CGImage.h.
kCGImageAlphaPremultipliedLast
The alpha component is stored in the least significant bits of each pixel and the color components have already been multiplied by this alpha value. For example, premultiplied RGBA.
Available in OS X v10.0 and later.
Declared in CGImage.h.