1 | /* CoreGraphics - CGImage.h |
---|
2 | * Copyright (c) 2000-2004 Apple Computer, Inc. |
---|
3 | * All rights reserved. |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef CGIMAGE_H_ |
---|
7 | #define CGIMAGE_H_ |
---|
8 | |
---|
9 | typedef struct CGImage *CGImageRef; |
---|
10 | |
---|
11 | #include <CoreGraphics/CGColorSpace.h> |
---|
12 | #include <CoreGraphics/CGDataProvider.h> |
---|
13 | #include <CoreGraphics/CGGeometry.h> |
---|
14 | |
---|
15 | CG_EXTERN_C_BEGIN |
---|
16 | |
---|
17 | enum CGImageAlphaInfo { |
---|
18 | kCGImageAlphaNone, /* For example, RGB. */ |
---|
19 | kCGImageAlphaPremultipliedLast, /* For example, premultiplied RGBA */ |
---|
20 | kCGImageAlphaPremultipliedFirst, /* For example, premultiplied ARGB */ |
---|
21 | kCGImageAlphaLast, /* For example, non-premultiplied RGBA */ |
---|
22 | kCGImageAlphaFirst, /* For example, non-premultiplied ARGB */ |
---|
23 | kCGImageAlphaNoneSkipLast, /* For example, RBGX. */ |
---|
24 | kCGImageAlphaNoneSkipFirst, /* For example, XRGB. */ |
---|
25 | kCGImageAlphaOnly /* No color data, alpha data only */ |
---|
26 | }; |
---|
27 | typedef enum CGImageAlphaInfo CGImageAlphaInfo; |
---|
28 | |
---|
29 | enum { |
---|
30 | kCGBitmapAlphaInfoMask = 0x1F, |
---|
31 | kCGBitmapFloatComponents = (1 << 8) |
---|
32 | }; |
---|
33 | typedef uint32_t CGBitmapInfo; /* Available in MAC OS X 10.4 & later. */ |
---|
34 | |
---|
35 | /* Return the CFTypeID for CGImageRefs. */ |
---|
36 | |
---|
37 | CG_EXTERN CFTypeID CGImageGetTypeID(void) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER; |
---|
38 | |
---|
39 | /* Create an image. */ |
---|
40 | |
---|
41 | CG_EXTERN CGImageRef CGImageCreate(size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGColorSpaceRef colorspace, CGBitmapInfo bitmapInfo, CGDataProviderRef provider, const float decode[], bool shouldInterpolate, CGColorRenderingIntent intent); |
---|
42 | |
---|
43 | /* Create an image mask. */ |
---|
44 | |
---|
45 | CG_EXTERN CGImageRef CGImageMaskCreate(size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGDataProviderRef provider, const float decode[], bool shouldInterpolate); |
---|
46 | |
---|
47 | /* Return a copy of `image'. Only the image structure itself is copied; the |
---|
48 | * underlying data is not. */ |
---|
49 | |
---|
50 | CG_EXTERN CGImageRef CGImageCreateCopy(CGImageRef image); |
---|
51 | |
---|
52 | /* Create an image from `source', a data provider of JPEG-encoded data. */ |
---|
53 | |
---|
54 | CG_EXTERN CGImageRef CGImageCreateWithJPEGDataProvider(CGDataProviderRef source, const float decode[], bool shouldInterpolate, CGColorRenderingIntent intent) AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER; |
---|
55 | |
---|
56 | /* Create an image using `source', a data provider for PNG-encoded data. */ |
---|
57 | |
---|
58 | CG_EXTERN CGImageRef CGImageCreateWithPNGDataProvider(CGDataProviderRef source, const float decode[], bool shouldInterpolate, CGColorRenderingIntent intent) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER; |
---|
59 | |
---|
60 | /* Create an image using the data contained within the subrectangle `rect' |
---|
61 | * of `image'. |
---|
62 | * |
---|
63 | * The new image is created by |
---|
64 | * 1) adjusting `rect' to integral bounds by calling "CGRectIntegral"; |
---|
65 | * 2) intersecting the result with a rectangle with origin (0, 0) and |
---|
66 | * size equal to the size of `image'; |
---|
67 | * 3) referencing the pixels within the resulting rectangle, treating the |
---|
68 | * first pixel of the image data as the origin of the image. |
---|
69 | * If the resulting rectangle is the null rectangle, this function returns |
---|
70 | * NULL. |
---|
71 | * |
---|
72 | * If W and H are the width and height of image, respectively, then the |
---|
73 | * point (0,0) corresponds to the first pixel of the image data; the point |
---|
74 | * (W-1, 0) is the last pixel of the first row of the image data; (0, H-1) |
---|
75 | * is the first pixel of the last row of the image data; and (W-1, H-1) is |
---|
76 | * the last pixel of the last row of the image data. |
---|
77 | * |
---|
78 | * The resulting image retains a reference to the original image, so you |
---|
79 | * may release the original image after calling this function. */ |
---|
80 | |
---|
81 | CG_EXTERN CGImageRef CGImageCreateWithImageInRect(CGImageRef image, CGRect rect) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; |
---|
82 | |
---|
83 | /* Create a new image from `image' masked by `mask', which may be an image |
---|
84 | * mask or an image. |
---|
85 | * |
---|
86 | * If `mask' is an image mask, then it indicates which parts of the context |
---|
87 | * are to be painted with the image when drawn in a context, and which are |
---|
88 | * to be masked out (left unchanged). The source samples of the image mask |
---|
89 | * determine which areas are painted, acting as an "inverse alpha": if the |
---|
90 | * value of a source sample in the image mask is S, then the corresponding |
---|
91 | * region in `image' is blended with the destination using an alpha of |
---|
92 | * (1-S). (For example, if S is 1, then the region is not painted, while |
---|
93 | * if S is 0, the region is fully painted.) |
---|
94 | * |
---|
95 | * If `mask' is an image, then it serves as alpha mask for blending the |
---|
96 | * image onto the destination. The source samples of `mask' determine |
---|
97 | * which areas are painted: if the value of the source sample in mask is S, |
---|
98 | * then the corresponding region in image is blended with the destination |
---|
99 | * with an alpha of S. (For example, if S is 0, then the region is not |
---|
100 | * painted, while if S is 1, the region is fully painted.) |
---|
101 | * |
---|
102 | * The parameter `image' may not be an image mask and may not have an image |
---|
103 | * mask or masking color associated with it. |
---|
104 | * |
---|
105 | * If `mask' is an image, then it must be in the DeviceGray color space, |
---|
106 | * may not have alpha, and may not itself be masked by an image mask |
---|
107 | * or a masking color. */ |
---|
108 | |
---|
109 | CG_EXTERN CGImageRef CGImageCreateWithMask(CGImageRef image, CGImageRef mask) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; |
---|
110 | |
---|
111 | /* Create a new image from `image' masked by `components', an array of 2N |
---|
112 | * values { min[1], max[1], ... min[N], max[N] } where N is the number of |
---|
113 | * components in color space of `image'. Any image sample with color value |
---|
114 | * {c[1], ... c[N]} where min[i] <= c[i] <= max[i] for 1 <= i <= N is |
---|
115 | * masked out (that is, not painted). |
---|
116 | * |
---|
117 | * Each value in `components' must be a valid image sample value: if |
---|
118 | * `image' has integral pixel components, then each value of must be in the |
---|
119 | * range [0 .. 2**bitsPerComponent - 1] (where `bitsPerComponent' is the |
---|
120 | * number of bits/component of `image'); if `image' has floating-point |
---|
121 | * pixel components, then each value may be any floating-point number which |
---|
122 | * is a valid color component. |
---|
123 | * |
---|
124 | * The parameter `image' may not be an image mask, and may not already have |
---|
125 | * an image mask or masking color associated with it. */ |
---|
126 | |
---|
127 | CG_EXTERN CGImageRef CGImageCreateWithMaskingColors(CGImageRef image, const float components[]) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; |
---|
128 | |
---|
129 | /* Create a copy of `image', replacing the image's colorspace with |
---|
130 | * `colorspace'. Returns NULL if `image' is an image mask, or if the |
---|
131 | * number of components of `colorspace' isn't the same as the number of |
---|
132 | * components of the colorspace of `image'. */ |
---|
133 | |
---|
134 | CG_EXTERN CGImageRef CGImageCreateCopyWithColorSpace(CGImageRef image, CGColorSpaceRef colorspace) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; |
---|
135 | |
---|
136 | /* Equivalent to `CFRetain(image)'. */ |
---|
137 | |
---|
138 | CG_EXTERN CGImageRef CGImageRetain(CGImageRef image); |
---|
139 | |
---|
140 | /* Equivalent to `CFRelease(image)'. */ |
---|
141 | |
---|
142 | CG_EXTERN void CGImageRelease(CGImageRef image); |
---|
143 | |
---|
144 | /* Return true if `image' is an image mask, false otherwise. */ |
---|
145 | |
---|
146 | CG_EXTERN bool CGImageIsMask(CGImageRef image); |
---|
147 | |
---|
148 | /* Return the width of `image'. */ |
---|
149 | |
---|
150 | CG_EXTERN size_t CGImageGetWidth(CGImageRef image); |
---|
151 | |
---|
152 | /* Return the height of `image'. */ |
---|
153 | |
---|
154 | CG_EXTERN size_t CGImageGetHeight(CGImageRef image); |
---|
155 | |
---|
156 | /* Return the number of bits/component of `image'. */ |
---|
157 | |
---|
158 | CG_EXTERN size_t CGImageGetBitsPerComponent(CGImageRef image); |
---|
159 | |
---|
160 | /* Return the number of bits/pixel of `image'. */ |
---|
161 | |
---|
162 | CG_EXTERN size_t CGImageGetBitsPerPixel(CGImageRef image); |
---|
163 | |
---|
164 | /* Return the number of bytes/row of `image'. */ |
---|
165 | |
---|
166 | CG_EXTERN size_t CGImageGetBytesPerRow(CGImageRef image); |
---|
167 | |
---|
168 | /* Return the colorspace of `image', or NULL if `image' is an image |
---|
169 | * mask. */ |
---|
170 | |
---|
171 | CG_EXTERN CGColorSpaceRef CGImageGetColorSpace(CGImageRef image); |
---|
172 | |
---|
173 | /* Return the alpha info of `image'. */ |
---|
174 | |
---|
175 | CG_EXTERN CGImageAlphaInfo CGImageGetAlphaInfo(CGImageRef image); |
---|
176 | |
---|
177 | /* Return the data provider of `image'. */ |
---|
178 | |
---|
179 | CG_EXTERN CGDataProviderRef CGImageGetDataProvider(CGImageRef image); |
---|
180 | |
---|
181 | /* Return the decode array of `image'. */ |
---|
182 | |
---|
183 | CG_EXTERN const float *CGImageGetDecode(CGImageRef image); |
---|
184 | |
---|
185 | /* Return the interpolation parameter of `image'. */ |
---|
186 | |
---|
187 | CG_EXTERN bool CGImageGetShouldInterpolate(CGImageRef image); |
---|
188 | |
---|
189 | /* Return the rendering intent of `image'. */ |
---|
190 | |
---|
191 | CG_EXTERN CGColorRenderingIntent CGImageGetRenderingIntent(CGImageRef image); |
---|
192 | |
---|
193 | /* Return the bitmap info of `image'. */ |
---|
194 | |
---|
195 | CG_EXTERN CGBitmapInfo CGImageGetBitmapInfo(CGImageRef image) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; |
---|
196 | |
---|
197 | CG_EXTERN_C_END |
---|
198 | |
---|
199 | #endif /* CGIMAGE_H_ */ |
---|