CGDirectPalette.pas 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. {
  2. * CGDirectPalette.h
  3. * CoreGraphics
  4. *
  5. * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  6. *
  7. }
  8. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  9. {
  10. Modified for use with Free Pascal
  11. Version 200
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$mode macpas}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$CALLING MWPASCAL}
  19. unit CGDirectPalette;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  22. {$setc GAP_INTERFACES_VERSION := $0200}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __i386__ and defined CPUI386}
  38. {$setc __i386__ := 1}
  39. {$elsec}
  40. {$setc __i386__ := 0}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  43. {$error Conflicting definitions for __ppc__ and __i386__}
  44. {$endc}
  45. {$ifc defined __ppc__ and __ppc__}
  46. {$setc TARGET_CPU_PPC := TRUE}
  47. {$setc TARGET_CPU_X86 := FALSE}
  48. {$elifc defined __i386__ and __i386__}
  49. {$setc TARGET_CPU_PPC := FALSE}
  50. {$setc TARGET_CPU_X86 := TRUE}
  51. {$elsec}
  52. {$error Neither __ppc__ nor __i386__ is defined.}
  53. {$endc}
  54. {$setc TARGET_CPU_PPC_64 := FALSE}
  55. {$ifc defined FPC_BIG_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  58. {$elifc defined FPC_LITTLE_ENDIAN}
  59. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  60. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  61. {$elsec}
  62. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  63. {$endc}
  64. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  65. {$setc CALL_NOT_IN_CARBON := FALSE}
  66. {$setc OLDROUTINENAMES := FALSE}
  67. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  68. {$setc OPAQUE_UPP_TYPES := TRUE}
  69. {$setc OTCARBONAPPLICATION := TRUE}
  70. {$setc OTKERNEL := FALSE}
  71. {$setc PM_USE_SESSION_APIS := TRUE}
  72. {$setc TARGET_API_MAC_CARBON := TRUE}
  73. {$setc TARGET_API_MAC_OS8 := FALSE}
  74. {$setc TARGET_API_MAC_OSX := TRUE}
  75. {$setc TARGET_CARBON := TRUE}
  76. {$setc TARGET_CPU_68K := FALSE}
  77. {$setc TARGET_CPU_MIPS := FALSE}
  78. {$setc TARGET_CPU_SPARC := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_UNIX := FALSE}
  81. {$setc TARGET_OS_WIN32 := FALSE}
  82. {$setc TARGET_RT_MAC_68881 := FALSE}
  83. {$setc TARGET_RT_MAC_CFM := FALSE}
  84. {$setc TARGET_RT_MAC_MACHO := TRUE}
  85. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  86. {$setc TYPE_BOOL := FALSE}
  87. {$setc TYPE_EXTENDED := FALSE}
  88. {$setc TYPE_LONGLONG := TRUE}
  89. uses MacTypes,CGDirectDisplay;
  90. {$ALIGN POWER}
  91. type
  92. CGPaletteBlendFraction = Float32; { A value between 0.0 and 1.0 }
  93. {
  94. * Convenient device color representation
  95. *
  96. * Values should be in the range from 0.0 to 1.0, where 0.0 is black, and 1.0
  97. * is full on for each channel.
  98. }
  99. type
  100. CGDeviceColorPtr = ^CGDeviceColor;
  101. CGDeviceColor = record
  102. red: Float32;
  103. green: Float32;
  104. blue: Float32;
  105. end;
  106. CGDeviceByteColorPtr = ^CGDeviceByteColor;
  107. CGDeviceByteColor = record
  108. red: SInt8;
  109. green: SInt8;
  110. blue: SInt8;
  111. end;
  112. {
  113. * Create a new palette object representing the default 8 bit color palette.
  114. * Release the palette using CGPaletteRelease().
  115. }
  116. function CGPaletteCreateDefaultColorPalette: CGDirectPaletteRef; external name '_CGPaletteCreateDefaultColorPalette';
  117. {
  118. * Create a copy of the display's current palette, if any.
  119. * Returns NULL if the current display mode does not support a palette.
  120. * Release the palette using CGPaletteRelease().
  121. }
  122. function CGPaletteCreateWithDisplay( display: CGDirectDisplayID ): CGDirectPaletteRef; external name '_CGPaletteCreateWithDisplay';
  123. {
  124. * Create a new palette with a capacity as specified. Entries are initialized from
  125. * the default color palette. Release the palette using CGPaletteRelease().
  126. }
  127. function CGPaletteCreateWithCapacity( capacity: CGTableCount ): CGDirectPaletteRef; external name '_CGPaletteCreateWithCapacity';
  128. {
  129. * Create a new palette with a capacity and contents as specified.
  130. * Release the palette using CGPaletteRelease().
  131. }
  132. function CGPaletteCreateWithSamples( var sampleTable: CGDeviceColor; sampleCount: CGTableCount ): CGDirectPaletteRef; external name '_CGPaletteCreateWithSamples';
  133. {
  134. * Convenience function:
  135. * Create a new palette with a capacity and contents as specified.
  136. * Release the palette using CGPaletteRelease().
  137. }
  138. function CGPaletteCreateWithByteSamples( var sampleTable: CGDeviceByteColor; sampleCount: CGTableCount ): CGDirectPaletteRef; external name '_CGPaletteCreateWithByteSamples';
  139. {
  140. * Release a palette
  141. }
  142. procedure CGPaletteRelease( palette: CGDirectPaletteRef ); external name '_CGPaletteRelease';
  143. {
  144. * Get the color value at the specified index
  145. }
  146. function CGPaletteGetColorAtIndex( palette: CGDirectPaletteRef; index: CGTableCount ): CGDeviceColor; external name '_CGPaletteGetColorAtIndex';
  147. {
  148. * Get the index for the specified color value
  149. * The index returned is for a palette color with the
  150. * lowest RMS error to the specified color.
  151. }
  152. function CGPaletteGetIndexForColor( palette: CGDirectPaletteRef; color: CGDeviceColor ): CGTableCount; external name '_CGPaletteGetIndexForColor';
  153. {
  154. * Get the number of samples in the palette
  155. }
  156. function CGPaletteGetNumberOfSamples( palette: CGDirectPaletteRef ): CGTableCount; external name '_CGPaletteGetNumberOfSamples';
  157. {
  158. * Set the color value at the specified index
  159. }
  160. procedure CGPaletteSetColorAtIndex( palette: CGDirectPaletteRef; color: CGDeviceColor; index: CGTableCount ); external name '_CGPaletteSetColorAtIndex';
  161. {
  162. * Copy a palette
  163. }
  164. function CGPaletteCreateCopy( palette: CGDirectPaletteRef ): CGDirectPaletteRef; external name '_CGPaletteCreateCopy';
  165. {
  166. * Compare two palettes
  167. }
  168. function CGPaletteIsEqualToPalette( palette1: CGDirectPaletteRef; palette2: CGDirectPaletteRef ): Boolean; external name '_CGPaletteIsEqualToPalette';
  169. {
  170. * Create a new palette blended with a fraction of a device color.
  171. * Free the resulting palette with CGPaletteRelease()
  172. }
  173. function CGPaletteCreateFromPaletteBlendedWithColor( palette: CGDirectPaletteRef; fraction: CGPaletteBlendFraction; color: CGDeviceColor ): CGDirectPaletteRef; external name '_CGPaletteCreateFromPaletteBlendedWithColor';
  174. end.