QDPictToCGContext.pas 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. {
  2. File: QD/QDPictToCGContext.h
  3. Contains: API to draw Quickdraw PICTs into CoreGraphics context
  4. Version: Quickdraw-150~1
  5. Copyright: © 2001-2003 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. }
  10. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit QDPictToCGContext;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,CGContext,CGGeometry,CGDataProvider,CFURL;
  92. {$ALIGN MAC68K}
  93. type
  94. QDPictRef = ^SInt32; { an opaque 32-bit type }
  95. {
  96. Note: QuickDraw picture data typically comes in two forms: a PICT resource
  97. that begins the picture header data at the beginning of the resource and PICT
  98. files that begin with 512 bytes of arbitrary data, followed by
  99. the picture header data. For this reason, the routines that create a QDPictRef
  100. attempt to find the picture header data beginning at either the first byte
  101. of the data provided or at byte 513 of the data provided.
  102. Additionally the Picture Bounds must not be an empty rect.
  103. }
  104. { Create a QDPict reference, using `provider' to obtain the QDPict's data.
  105. * It is assumed that either the first byte or the 513th byte of data
  106. * in the file referenced by the URL is the first byte of the
  107. * picture header. If the URL does not begin PICT data at one
  108. * of these places in the data fork then the QDPictRef returned will be NULL.
  109. }
  110. {
  111. * QDPictCreateWithProvider()
  112. *
  113. * Availability:
  114. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  115. * CarbonLib: not available
  116. * Non-Carbon CFM: not available
  117. }
  118. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  119. function QDPictCreateWithProvider( provider: CGDataProviderRef ): QDPictRef; external name '_QDPictCreateWithProvider';
  120. { Create a QDPict reference from `url'.
  121. * It is assumed that either the first byte or the 513th byte of data
  122. * in the file referenced by the URL is the first byte of the
  123. * picture header. If the URL does not begin PICT data at one
  124. * of these places in the data fork then the QDPictRef returned will be NULL.
  125. }
  126. {
  127. * QDPictCreateWithURL()
  128. *
  129. * Availability:
  130. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  131. * CarbonLib: not available
  132. * Non-Carbon CFM: not available
  133. }
  134. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  135. function QDPictCreateWithURL( url: CFURLRef ): QDPictRef; external name '_QDPictCreateWithURL';
  136. { Increment the retain count of `pictRef' and return it. All
  137. * pictRefs are created with an initial retain count of 1. }
  138. {
  139. * QDPictRetain()
  140. *
  141. * Availability:
  142. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  143. * CarbonLib: not available
  144. * Non-Carbon CFM: not available
  145. }
  146. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  147. function QDPictRetain( pictRef: QDPictRef ): QDPictRef; external name '_QDPictRetain';
  148. { Decrement the retain count of `pictRef'. If the retain count reaches 0,
  149. * then free it and any associated resources. }
  150. {
  151. * QDPictRelease()
  152. *
  153. * Availability:
  154. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  155. * CarbonLib: not available
  156. * Non-Carbon CFM: not available
  157. }
  158. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  159. procedure QDPictRelease( pictRef: QDPictRef ); external name '_QDPictRelease';
  160. { Return the Picture Bounds of the QuickDraw picture represented by `pictRef'. This
  161. rectangle is in the default user space with one unit = 1/72 inch.
  162. }
  163. {
  164. * QDPictGetBounds()
  165. *
  166. * Availability:
  167. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  168. * CarbonLib: not available
  169. * Non-Carbon CFM: not available
  170. }
  171. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  172. function QDPictGetBounds( pictRef: QDPictRef ): CGRect; external name '_QDPictGetBounds';
  173. { Return the resolution of the QuickDraw picture represented by `pictRef'.
  174. This data, together with the CGRect returned by QDPictGetBounds, can be
  175. used to compute the size of the picture in pixels, which is what QuickDraw
  176. really records into pictures.
  177. }
  178. {
  179. * QDPictGetResolution()
  180. *
  181. * Availability:
  182. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  183. * CarbonLib: not available
  184. * Non-Carbon CFM: not available
  185. }
  186. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  187. procedure QDPictGetResolution( pictRef: QDPictRef; var xRes, yRes: Float32 ); external name '_QDPictGetResolution';
  188. { Draw `pictRef' in the rectangular area specified by `rect'.
  189. * The PICT bounds of the page is scaled, if necessary, to fit into
  190. * `rect'. To get unscaled results, supply a rect the size of the rect
  191. * returned by QDPictGetBounds.
  192. }
  193. {
  194. * QDPictDrawToCGContext()
  195. *
  196. * Availability:
  197. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  198. * CarbonLib: not available
  199. * Non-Carbon CFM: not available
  200. }
  201. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  202. function QDPictDrawToCGContext( ctx: CGContextRef; rect: CGRect; pictRef: QDPictRef ): OSStatus; external name '_QDPictDrawToCGContext';
  203. end.