# CGImageRef 的 参数解释

CGImageRef CGImageCreate (
   size_t width,
   size_t height,
   size_t bitsPerComponent,
   size_t bitsPerPixel,
   size_t bytesPerRow,
   CGColorSpaceRef colorspace,
   CGBitmapInfo bitmapInfo,
   CGDataProviderRef provider,
   const CGFloat decode[],
   bool shouldInterpolate,
   CGColorRenderingIntent intent
);
Sample: width = 500; height = 500; bitsPerComponent = 8;// RGBA bitsPerPixel = 32; //RGBA bytesPerRow = (32/8)*500; (bitsPerPixel/bitsPerComponent)*width, bitsPerPixel/bitsPerComponent is bytes per pixel colorspace = CGContextGetDeviceRGB(); bitmapInfo =

kCGImageAlphaPremultipliedLast

provider = CGDataProviderRef;

decode

width

The width, in pixels, of the required image. 图像的宽度

height

The height, in pixels, of the required image 图像的高度

bitsPerComponent

The number of bits for each component in a source pixel. For example, if the source image uses the RGBA-32 format, you would specify 8 bits per component.

bitsPerPixel

The total number of bits in a source pixel. This value must be at least bitsPerComponent times the number of components per pixel.

bytesPerRow

The number of bytes of memory for each horizontal row of the bitmap.

colorspace

The color space for the image. Quartz retains the color space you pass in; on return, you may safely release it.

bitmapInfo

CGBitmapInfo constant that specifies whether the bitmap should contain an alpha channel and its relative location in a pixel, along with whether the components are floating-point or integer values.

provider

The source of data for the bitmap. For information about supported data formats, see the discussion below. Quartz retains this object; on return, you may safely release it.

decode

The decode array for the image. If you do not want to allow remapping of the image’s color values, pass NULL for the decode array. For each color component in the image’s color space (including the alpha component), a decode array provides a pair of values denoting the upper and lower limits of a range. For example, the decode array for a source image in the RGB color space would contain six entries total, consisting of one pair each for red, green, and blue. When the image is rendered, Quartz uses a linear transform to map the original component value into a relative number within your designated range that is appropriate for the destination color space.

shouldInterpolate

A Boolean value that specifies whether interpolation should occur. The interpolation setting specifies whether Quartz should apply a pixel-smoothing algorithm to the image. Without interpolation, the image may appear jagged or pixelated when drawn on an output device with higher resolution than the image data.

intent

A rendering intent constant that specifies how Quartz should handle colors that are not located within the gamut of the destination color space of a graphics context. The rendering intent determines the exact method used to map colors from one color space to another. For descriptions of the defined rendering-intent constants, see Color Rendering Intents.

• 本文已收录于以下专栏：

举报原因： 您举报文章：CGImageRef 的 参数解释 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)