大家好,欢迎来到IT知识分享网。
1,CGColorSpaceRef:An opaque type that encapsulates color space information.
2,CGColorSpaceModel:
enum CGColorSpaceModel {
kCGColorSpaceModelUnknown = -1,
kCGColorSpaceModelMonochrome,
kCGColorSpaceModelRGB,
kCGColorSpaceModelCMYK,
kCGColorSpaceModelLab,
kCGColorSpaceModelDeviceN,
kCGColorSpaceModelIndexed,
kCGColorSpaceModelPattern };
typedef int32_t CGColorSpaceModel;
3, CGImageGetColorSpace(CGImageRef image):Return the color space for a bitmap image.
4,CGColorSpaceGetNumberOfComponents:Returns the number of color components in a color space.
size_t CGColorSpaceGetNumberOfComponents(
CGColorSpaceRef cs
);
The number of color components in the specified color space, not including the alpha value. For example, for an RGB color space,
5,
CGColorSpaceGetModel
Returns the color space model of the provided color space.
CGColorSpaceModel CGColorSpaceGetModel(
CGColorSpaceRef space
);
Parameters
space
A color space object.
Return Value
One of the constants described in “Color Space Models”.
6,
CGColorSpaceCreateIndexed
Creates an indexed color space, consisting of colors specified by a color lookup table.
CGColorSpaceRef CGColorSpaceCreateIndexed(
CGColorSpaceRef baseSpace,
size_t lastIndex,
const unsigned char *colorTable
);
Parameters
baseSpace
The color space on which the color table is based.
lastIndex
The maximum valid index value for the color table. The value must be less than or equal to 255.
colorTable
An array of m*(lastIndex+1) bytes, where m is the number of color components in the base color space. Each byte is an unsigned integer in the range 0 to 255
7,
CGColorSpaceCreateDeviceRGB
Creates a device-dependent RGB color space.
CGColorSpaceRef CGColorSpaceCreateDeviceRGB(
void
);
Return Value
A device-dependent RGB color space. You are responsible for releasing this object by calling CGColorSpaceRelease. If unsuccessful, returns NULL.
8,
CGImageCreateCopyWithColorSpace
Create a copy of a bitmap image, replacing its colorspace.
CGImageRef CGImageCreateCopyWithColorSpace (
CGImageRef image,
CGColorSpaceRef colorspace
);
Parameters
image
The graphics image to copy.
colorspace
The destination color space. The number of components in this color space must be the same as the number in the specified image.
9,
CGImageRef
An opaque type that encapsulates bitmap image information.
typedef struct CGImage *CGImageRef;
10,
CGColorRef
An opaque type that represents a color used in Quartz 2D drawing.
typedef struct CGColor *CGColorRef;
Discussion
CGColorRef is the fundamental data type used internally by Quartz to represent colors. CGColor objects, and the functions that operate on them, provide a fast and convenient way of managing and setting colors directly, especially colors that are reused (such as black for text).
11,
CGColorGetComponents
Returns the values of the color components (including alpha) associated with a Quartz color.
const CGFloat * CGColorGetComponents (
CGColorRef color
);
Parameters
color
A Quartz color.
Return Value
An array of intensity values for the color components (including alpha) associated with the specified color. The size of the array is one more than the number of components of the color space for the color.
12,memcpy
函数原型
void *memcpy(void*dest, const void *src, size_t n);
功能
由src指向地址为起始地址的连续n个字节的数据复制到以destin指向地址为起始地址的空间内。
头文件
#include<string.h>
返回值
函数返回一个指向dest的指针。
说明
1.source和destin所指内存区域不能重叠,函数返回指向destin的指针。
2.与strcpy相比,memcpy并不是遇到’\0’就结束,而是一定会拷贝完n个字节。
memcpy用来做内存拷贝,你可以拿它拷贝任何数据类型的对象,可以指定拷贝的数据长度;
例:
char a[100], b[50];
memcpy(b, a,sizeof(b)); //注意如用sizeof(a),会造成b的内存地址溢出。
strcpy就只能拷贝字符串了,它遇到’\0’就结束拷贝;例:
char a[100], b[50];
strcpy(a,b);
3.如果目标数组destin本身已有数据,执行memcpy()后,将覆盖原有数据(最多覆盖n)。如果要追加数据,则每次执行memcpy后,要将目标数组地址增加到你要追加数据的地址。
//注意,source和destin都不一定是数组,任意的可读写的空间均可。
程序例
13,
CGBitmapContextCreate
Creates a bitmap graphics context.
CGContextRef CGBitmapContextCreate (
void *data,
size_t width,
size_t height,
size_t bitsPerComponent,
size_t bytesPerRow,
CGColorSpaceRef colorspace,
CGBitmapInfo bitmapInfo
);
Parameters
data
A pointer to the destination in memory where the drawing is to be rendered. The size of this memory block should be at least (bytesPerRow*height) bytes.
In iOS 4.0 and later, and OS X v10.6 and later, you can pass NULL if you want Quartz to allocate memory for the bitmap. This frees you from managing your own memory, which reduces memory leak issues.
width
The width, in pixels, of the required bitmap.
height
The height, in pixels, of the required bitmap.
bitsPerComponent
The number of bits to use for each component of a pixel in memory. For example, for a 32-bit pixel format and an RGB color space, you would specify a value of 8 bits per component. For the list of supported pixel formats, see “Supported Pixel Formats” in the “Graphics Contexts” chapter of Quartz 2D Programming Guide.
bytesPerRow
The number of bytes of memory to use per row of the bitmap. If the data parameter is NULL, passing a value of 0 causes the value to be calculated automatically.
colorspace
The color space to use for the bitmap context. Note that indexed color spaces are not supported for bitmap graphics contexts.
bitmapInfo
Constants that specify whether the bitmap should contain an alpha channel, the alpha channel’s relative location in a pixel, and information about whether the pixel components are floating-point or integer values. The constants for specifying the alpha channel information are declared with the CGImageAlphaInfo type but can be passed to this parameter safely. You can also pass the other constants associated with the CGBitmapInfo type. (See CGImage Reference for a description of the CGBitmapInfo and CGImageAlphaInfo constants.)
For an example of how to specify the color space, bits per pixel, bits per pixel component, and bitmap information using the CGBitmapContextCreate function, see “Creating a Bitmap Graphics Context” in the “Graphics Contexts” chapter of Quartz 2D Programming Guide.
Return Value
A new bitmap context, or NULL if a context could not be created. You are responsible for releasing this object using CGContextRelease.
转载于:https://www.cnblogs.com/guligei/p/3583545.html
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/10846.html