CGColorSpace.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. { CoreGraphics - CGColorSpace.h
  2. * Copyright (c) 1999-2004 Apple Computer, Inc.
  3. * All rights reserved.
  4. }
  5. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  6. { Pascal Translation Updated: Gale R Paeper, <[email protected]>, 2006 }
  7. {
  8. Modified for use with Free Pascal
  9. Version 200
  10. Please report any bugs to <[email protected]>
  11. }
  12. {$mode macpas}
  13. {$packenum 1}
  14. {$macro on}
  15. {$inline on}
  16. {$CALLING MWPASCAL}
  17. unit CGColorSpace;
  18. interface
  19. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  20. {$setc GAP_INTERFACES_VERSION := $0200}
  21. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  22. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  23. {$endc}
  24. {$ifc defined CPUPOWERPC and defined CPUI386}
  25. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  26. {$endc}
  27. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  28. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  29. {$endc}
  30. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  31. {$setc __ppc__ := 1}
  32. {$elsec}
  33. {$setc __ppc__ := 0}
  34. {$endc}
  35. {$ifc not defined __i386__ and defined CPUI386}
  36. {$setc __i386__ := 1}
  37. {$elsec}
  38. {$setc __i386__ := 0}
  39. {$endc}
  40. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  41. {$error Conflicting definitions for __ppc__ and __i386__}
  42. {$endc}
  43. {$ifc defined __ppc__ and __ppc__}
  44. {$setc TARGET_CPU_PPC := TRUE}
  45. {$setc TARGET_CPU_X86 := FALSE}
  46. {$elifc defined __i386__ and __i386__}
  47. {$setc TARGET_CPU_PPC := FALSE}
  48. {$setc TARGET_CPU_X86 := TRUE}
  49. {$elsec}
  50. {$error Neither __ppc__ nor __i386__ is defined.}
  51. {$endc}
  52. {$setc TARGET_CPU_PPC_64 := FALSE}
  53. {$ifc defined FPC_BIG_ENDIAN}
  54. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  55. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  56. {$elifc defined FPC_LITTLE_ENDIAN}
  57. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  58. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  59. {$elsec}
  60. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  61. {$endc}
  62. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  63. {$setc CALL_NOT_IN_CARBON := FALSE}
  64. {$setc OLDROUTINENAMES := FALSE}
  65. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  66. {$setc OPAQUE_UPP_TYPES := TRUE}
  67. {$setc OTCARBONAPPLICATION := TRUE}
  68. {$setc OTKERNEL := FALSE}
  69. {$setc PM_USE_SESSION_APIS := TRUE}
  70. {$setc TARGET_API_MAC_CARBON := TRUE}
  71. {$setc TARGET_API_MAC_OS8 := FALSE}
  72. {$setc TARGET_API_MAC_OSX := TRUE}
  73. {$setc TARGET_CARBON := TRUE}
  74. {$setc TARGET_CPU_68K := FALSE}
  75. {$setc TARGET_CPU_MIPS := FALSE}
  76. {$setc TARGET_CPU_SPARC := FALSE}
  77. {$setc TARGET_OS_MAC := TRUE}
  78. {$setc TARGET_OS_UNIX := FALSE}
  79. {$setc TARGET_OS_WIN32 := FALSE}
  80. {$setc TARGET_RT_MAC_68881 := FALSE}
  81. {$setc TARGET_RT_MAC_CFM := FALSE}
  82. {$setc TARGET_RT_MAC_MACHO := TRUE}
  83. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  84. {$setc TYPE_BOOL := FALSE}
  85. {$setc TYPE_EXTENDED := FALSE}
  86. {$setc TYPE_LONGLONG := TRUE}
  87. uses MacTypes,CFBase,CFString,CMTypes,CGBase,CGDataProvider;
  88. {$ALIGN POWER}
  89. type
  90. CGColorSpaceRef = ^SInt32; { an opaque 32-bit type }
  91. type
  92. TristimulusValue = array[0..2] of Float32;
  93. RedGreenBlueValue = array[0..2] of Float32;
  94. Single4 = array[0..3] of Float32;
  95. Single9 = array[0..8] of Float32;
  96. type
  97. CGColorRenderingIntent = SInt32;
  98. const
  99. kCGRenderingIntentDefault = 0;
  100. kCGRenderingIntentAbsoluteColorimetric = 1;
  101. kCGRenderingIntentRelativeColorimetric = 2;
  102. kCGRenderingIntentPerceptual = 3;
  103. kCGRenderingIntentSaturation = 4;
  104. var kCGColorSpaceGenericGray: CFStringRef; external name '_kCGColorSpaceGenericGray'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  105. var kCGColorSpaceGenericRGB: CFStringRef; external name '_kCGColorSpaceGenericRGB'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  106. var kCGColorSpaceGenericCMYK: CFStringRef; external name '_kCGColorSpaceGenericCMYK'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  107. { Return the CFTypeID for CGColorSpaces. }
  108. function CGColorSpaceGetTypeID: CFTypeID; external name '_CGColorSpaceGetTypeID'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  109. {* Device-dependent color spaces. *}
  110. { Create a DeviceGray colorspace. }
  111. function CGColorSpaceCreateDeviceGray: CGColorSpaceRef; external name '_CGColorSpaceCreateDeviceGray';
  112. { Create a DeviceRGB colorspace. }
  113. function CGColorSpaceCreateDeviceRGB: CGColorSpaceRef; external name '_CGColorSpaceCreateDeviceRGB';
  114. { Create a DeviceCMYK colorspace. }
  115. function CGColorSpaceCreateDeviceCMYK: CGColorSpaceRef; external name '_CGColorSpaceCreateDeviceCMYK';
  116. {* Device-independent color spaces. *}
  117. { Create a calibrated gray colorspace. `whitePoint' is an array of 3
  118. * numbers specifying the tristimulus value, in the CIE 1931 XYZ-space, of
  119. * the diffuse white point. `blackPoint' is an array of 3 numbers
  120. * specifying the tristimulus value, in CIE 1931 XYZ-space, of the diffuse
  121. * black point. `gamma' defines the gamma for the gray component. }
  122. function CGColorSpaceCreateCalibratedGray( const (*var*) whitePoint: TristimulusValue; const (*var*) blackPoint: TristimulusValue; gamma: Float32 ): CGColorSpaceRef; external name '_CGColorSpaceCreateCalibratedGray';
  123. { Create a calibrated RGB colorspace. `whitePoint' is an array of 3
  124. * numbers specifying the tristimulus value, in the CIE 1931 XYZ-space, of
  125. * the diffuse white point. `blackPoint' is an array of 3 numbers
  126. * specifying the tristimulus value, in CIE 1931 XYZ-space, of the diffuse
  127. * black point. `gamma' is an array of 3 numbers specifying the gamma for
  128. * the red, green, and blue components of the color space. `matrix' is an
  129. * array of 9 numbers specifying the linear interpretation of the
  130. * gamma-modified RGB values of the colorspace with respect to the final
  131. * XYZ representation. }
  132. function CGColorSpaceCreateCalibratedRGB( const (*var*) whitePoint: TristimulusValue; const (*var*) blackPoint: TristimulusValue; const (*var*) gamma: RedGreenBlueValue; const (*var*) matrix: Single9 ): CGColorSpaceRef; external name '_CGColorSpaceCreateCalibratedRGB';
  133. { Create an L*a*b* colorspace. `whitePoint' is an array of 3 numbers
  134. * specifying the tristimulus value, in the CIE 1931 XYZ-space, of the
  135. * diffuse white point. `blackPoint' is an array of 3 numbers specifying
  136. * the tristimulus value, in CIE 1931 XYZ-space, of the diffuse black
  137. * point. `range' is an array of four numbers specifying the range of valid
  138. * values for the a* and b* components of the color space. }
  139. function CGColorSpaceCreateLab(const (*var*) whitePoint: TristimulusValue; const (*var*) blackPoint: TristimulusValue; const (*var*) range: Single4): CGColorSpaceRef; external name '_CGColorSpaceCreateLab';
  140. { Create an ICC-based colorspace. `nComponents' specifies the number of
  141. * color components in the color space defined by the ICC profile data.
  142. * This must match the number of components actually in the ICC profile,
  143. * and must be 1, 3, or 4. `range' is an array of 2*nComponents numbers
  144. * specifying the minimum and maximum valid values of the corresponding
  145. * color components, so that for color component k, range[2*k] <= c[k] <=
  146. * range[2*k+1], where c[k] is the k'th color component. `profile' is a
  147. * data provider specifying the ICC profile. `alternate' specifies an
  148. * alternate colorspace to be used in case the ICC profile is not
  149. * supported. It must have `nComponents' color components. If `alternate'
  150. * is NULL, then the color space used will be DeviceGray, DeviceRGB, or
  151. * DeviceCMYK, depending on whether `nComponents' is 1, 3, or 4,
  152. * respectively. }
  153. function CGColorSpaceCreateICCBased( nComponents: size_t; {const} range: {variable-size-array} Float32Ptr; profile: CGDataProviderRef; alternate: CGColorSpaceRef ): CGColorSpaceRef; external name '_CGColorSpaceCreateICCBased';
  154. {* Special colorspaces. *}
  155. { Create an indexed colorspace. A sample value in an indexed color space
  156. * is treated as an index into the color table of the color space. `base'
  157. * specifies the base color space in which the values in the color table
  158. * are to be interpreted. `lastIndex' is an integer which specifies the
  159. * maximum valid index value; it must be less than or equal to 255.
  160. * `colorTable' is an array of m * (lastIndex + 1) bytes, where m is
  161. * the number of color components in the base color space. Each byte
  162. * is an unsigned integer in the range 0 to 255 that is scaled to the
  163. * range of the corresponding color component in the base color space. }
  164. function CGColorSpaceCreateIndexed( baseSpace: CGColorSpaceRef; lastIndex: size_t; colorTable: UInt8Ptr ): CGColorSpaceRef; external name '_CGColorSpaceCreateIndexed';
  165. { Create a pattern colorspace. `baseSpace' is the underlying colorspace of
  166. * the pattern colorspace. For colored patterns, `baseSpace' should be
  167. * NULL; for uncolored patterns, `baseSpace' specifies the colorspace of
  168. * colors which will be painted through the pattern. }
  169. function CGColorSpaceCreatePattern( baseSpace: CGColorSpaceRef ): CGColorSpaceRef; external name '_CGColorSpaceCreatePattern';
  170. { Create a CGColorSpace using `platformColorSpaceReference', a
  171. * platform-specific color space reference. For MacOS X,
  172. * `platformColorSpaceReference' should be a CMProfileRef. }
  173. function CGColorSpaceCreateWithPlatformColorSpace( platformColorSpaceReference: UnivPtr ): CGColorSpaceRef; external name '_CGColorSpaceCreateWithPlatformColorSpace';
  174. { Create a colorspace using `name' as the identifier for the colorspace. }
  175. function CGColorSpaceCreateWithName( name: CFStringRef ): CGColorSpaceRef; external name '_CGColorSpaceCreateWithName'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  176. {* Colorspace information. *}
  177. { Return the number of color components in the colorspace `cs'. }
  178. function CGColorSpaceGetNumberOfComponents( cs: CGColorSpaceRef ): size_t; external name '_CGColorSpaceGetNumberOfComponents';
  179. {* Retaining & releasing colorspaces. *}
  180. { Equivalent to `CFRetain(cs)'. }
  181. function CGColorSpaceRetain( cs: CGColorSpaceRef ): CGColorSpaceRef; external name '_CGColorSpaceRetain';
  182. { Equivalent to `CFRelease(cs)'. }
  183. procedure CGColorSpaceRelease( cs: CGColorSpaceRef ); external name '_CGColorSpaceRelease';
  184. {* Deprecated APIs. *}
  185. { Use "kCGColorSpaceGenericGray" instead. }
  186. {$ifc USE_CFSTR_CONSTANT_MACROS}
  187. {$definec kCGColorSpaceUserGray CFSTRP('kCGColorSpaceUserGray')}
  188. {$endc}
  189. { Use "kCGColorSpaceGenericRGB" instead. }
  190. {$ifc USE_CFSTR_CONSTANT_MACROS}
  191. {$definec kCGColorSpaceUserRGB CFSTRP('kCGColorSpaceUserRGB')}
  192. {$endc}
  193. { Use "kCGColorSpaceGenericCMYK" instead. }
  194. {$ifc USE_CFSTR_CONSTANT_MACROS}
  195. {$definec kCGColorSpaceUserCMYK CFSTRP('kCGColorSpaceUserCMYK')}
  196. {$endc}
  197. end.