CGColorSpace.pas 10 KB

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