Untitled


SUBMITTED BY: Guest

DATE: Nov. 25, 2014, 7:20 a.m.

FORMAT: Text only

SIZE: 10.6 kB

HITS: 48100

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

comments powered by Disqus