CGImageSource.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. {
  2. * ImageIO - CGImageSource.h
  3. * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  4. *
  5. }
  6. { Pascal Translation: 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 CGImageSource;
  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, CFArray, CFBase, CFData, CFDictionary, CFURL, CGDataProvider, CGImage;
  88. {$ALIGN POWER}
  89. type
  90. CGImageSourceRef = ^SInt32; { an opaque 32-bit type }
  91. type
  92. CGImageSourceStatus = SInt32;
  93. const
  94. kCGImageStatusUnexpectedEOF = -5;
  95. kCGImageStatusInvalidData = -4;
  96. kCGImageStatusUnknownType = -3;
  97. kCGImageStatusReadingHeader = -2;
  98. kCGImageStatusIncomplete = -1;
  99. kCGImageStatusComplete = 0;
  100. {* Keys for the options dictionary when creating a CGImageSourceRef. *}
  101. { Specifies the "best guess" of the type identifier for the format of the
  102. * image source file. If specified, the value of this key must be a
  103. * CFStringRef. For more information about type identifiers, see "UTType.h"
  104. * in the Application Services framework. }
  105. var kCGImageSourceTypeIdentifierHint: CFStringRef; external name '_kCGImageSourceTypeIdentifierHint'; (* attribute const *)
  106. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  107. {* Keys for the options dictionary of "CGImageSourceCopyPropertiesAtIndex"
  108. ** and "CGImageSourceCreateImageAtIndex". *}
  109. { Specifies whether the image should be cached in a decoded form. The
  110. * value of this key must be a CFBooleanRef; the default value is
  111. * kCFBooleanFalse. }
  112. var kCGImageSourceShouldCache: CFStringRef; external name '_kCGImageSourceShouldCache'; (* attribute const *)
  113. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  114. { Specifies whether the image should be returned as a floating
  115. * point CGImageRef if supported by the file format. Extended
  116. * range floating point CGImageRef may require additional
  117. * processing to render pleasingly. The value of this key must
  118. * be a CFBooleanRef; the default value is kCFBooleanFalse. }
  119. var kCGImageSourceShouldAllowFloat: CFStringRef; external name '_kCGImageSourceShouldAllowFloat'; (* attribute const *)
  120. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  121. {* Keys for the options dictionary of
  122. ** "CGImageSourceCreateThumbnailAtIndex". *}
  123. { Specifies whether a thumbnail should be automatically created for an
  124. * image if a thumbnail isn't present in the image source file. The
  125. * thumbnail will be created from the full image, subject to the limit
  126. * specified by kCGImageSourceThumbnailMaxPixelSize---if a maximum pixel
  127. * size isn't specified, then the thumbnail will be the size of the full
  128. * image, which probably isn't what you want. The value of this key must be
  129. * a CFBooleanRef; the default value of this key is kCFBooleanFalse. }
  130. var kCGImageSourceCreateThumbnailFromImageIfAbsent: CFStringRef; external name '_kCGImageSourceCreateThumbnailFromImageIfAbsent'; (* attribute const *)
  131. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  132. { Specifies whether a thumbnail should be created from the full image even
  133. * if a thumbnail is present in the image source file. The thumbnail will
  134. * be created from the full image, subject to the limit specified by
  135. * kCGImageSourceThumbnailMaxPixelSize---if a maximum pixel size isn't
  136. * specified, then the thumbnail will be the size of the full image, which
  137. * probably isn't what you want. The value of this key must be a
  138. * CFBooleanRef; the default value of this key is kCFBooleanFalse. }
  139. var kCGImageSourceCreateThumbnailFromImageAlways: CFStringRef; external name '_kCGImageSourceCreateThumbnailFromImageAlways'; (* attribute const *)
  140. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  141. { Specifies the maximum width and height in pixels of a thumbnail. If
  142. * this this key is not specified, the width and height of a thumbnail is
  143. * not limited and thumbnails may be as big as the image itself. If
  144. * present, this value of this key must be a CFNumberRef. }
  145. var kCGImageSourceThumbnailMaxPixelSize: CFStringRef; external name '_kCGImageSourceThumbnailMaxPixelSize'; (* attribute const *)
  146. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  147. { Specifies whether the thumbnail should be rotated and scaled according
  148. * to the orientation and pixel aspect ratio of the full image. The value
  149. * of this key must be a CFBooleanRef; the default value of this key is
  150. * kCFBooleanFalse. }
  151. var kCGImageSourceCreateThumbnailWithTransform: CFStringRef; external name '_kCGImageSourceCreateThumbnailWithTransform'; (* attribute const *)
  152. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  153. { Return the CFTypeID for CGImageSources. }
  154. function CGImageSourceGetTypeID: CFTypeID; external name '_CGImageSourceGetTypeID';
  155. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  156. { Return an array of supported type identifiers. }
  157. function CGImageSourceCopyTypeIdentifiers: CFArrayRef; external name '_CGImageSourceCopyTypeIdentifiers';
  158. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  159. { Create an image source reading from the data provider `provider'. The
  160. * `options' dictionary may be used to request additional creation options;
  161. * see the list of keys above for more information. }
  162. function CGImageSourceCreateWithDataProvider( provider: CGDataProviderRef; options: CFDictionaryRef ): CGImageSourceRef; external name '_CGImageSourceCreateWithDataProvider';
  163. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  164. { Create an image source reading from `data'. The `options' dictionary
  165. * may be used to request additional creation options; see the list of keys
  166. * above for more information. }
  167. function CGImageSourceCreateWithData( data: CFDataRef; options: CFDictionaryRef ): CGImageSourceRef; external name '_CGImageSourceCreateWithData';
  168. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  169. { Create an image source reading from `url'. The `options' dictionary may
  170. * be used to request additional creation options; see the list of keys
  171. * above for more information. }
  172. function CGImageSourceCreateWithURL( url: CFURLRef; options: CFDictionaryRef ): CGImageSourceRef; external name '_CGImageSourceCreateWithURL';
  173. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  174. { Return the type identifier of the image source `isrc'. This type is the
  175. * type of the source "container", which is not necessarily the type of the
  176. * image(s) in the container. For example, the .icns format supports
  177. * embedded JPEG2000 but the source type will be "com.apple.icns". }
  178. function CGImageSourceGetType( isrc: CGImageSourceRef ): CFStringRef; external name '_CGImageSourceGetType';
  179. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  180. { Return the number of images (not including thumbnails) in the image
  181. * source `isrc'. }
  182. function CGImageSourceGetCount( isrc: CGImageSourceRef ): size_t; external name '_CGImageSourceGetCount';
  183. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  184. { Return the properties of the image source `isrc'. These properties
  185. * apply to the container in general but not necessarily to any individual
  186. * image that it contains. }
  187. function CGImageSourceCopyProperties( isrc: CGImageSourceRef; options: CFDictionaryRef ): CFDictionaryRef; external name '_CGImageSourceCopyProperties';
  188. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  189. { Return the properties of the image at `index' in the image source
  190. * `isrc'. The index is zero-based. The `options' dictionary may be used
  191. * to request additional options; see the list of keys above for more
  192. * information. }
  193. function CGImageSourceCopyPropertiesAtIndex( isrc: CGImageSourceRef; index: size_t; options: CFDictionaryRef ): CFDictionaryRef; external name '_CGImageSourceCopyPropertiesAtIndex';
  194. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  195. { Return the image at `index' in the image source `isrc'. The index is
  196. * zero-based. The `options' dictionary may be used to request additional
  197. * creation options; see the list of keys above for more information. }
  198. function CGImageSourceCreateImageAtIndex( isrc: CGImageSourceRef; index: size_t; options: CFDictionaryRef ): CGImageRef; external name '_CGImageSourceCreateImageAtIndex';
  199. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  200. { Return the thumbnail of the image at `index' in the image source `isrc'.
  201. * The index is zero-based. The `options' dictionary may be used to request
  202. * additional thumbnail creation options; see the list of keys above for
  203. * more information. }
  204. function CGImageSourceCreateThumbnailAtIndex( isrc: CGImageSourceRef; index: size_t; options: CFDictionaryRef ): CGImageRef; external name '_CGImageSourceCreateThumbnailAtIndex';
  205. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  206. { Create an incremental image source. No data is provided at creation
  207. * time; it is assumed that data will eventually be provided using
  208. * "CGImageSourceUpdateDataProvider" or "CGImageSourceUpdateData". The
  209. * `options' dictionary may be used to request additional creation options;
  210. * see the list of keys above for more information. }
  211. function CGImageSourceCreateIncremental( options: CFDictionaryRef ): CGImageSourceRef; external name '_CGImageSourceCreateIncremental';
  212. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  213. { Update the incremental image source `isrc' with new data. The new data
  214. * must include all the previous data plus any additional new data. The
  215. * `final' parameter should be true when the final set of data is provided;
  216. * false otherwise. }
  217. procedure CGImageSourceUpdateData( isrc: CGImageSourceRef; data: CFDataRef; final: CBool ); external name '_CGImageSourceUpdateData';
  218. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  219. { Update the incremental image source `isrc' with a new data provider.
  220. * The new data provider must provide all the previous data plus any
  221. * additional new data. The `final' parameter should be true when the final
  222. * set of data is provided; false otherwise. }
  223. procedure CGImageSourceUpdateDataProvider( isrc: CGImageSourceRef; provider: CGDataProviderRef; final: CBool ); external name '_CGImageSourceUpdateDataProvider';
  224. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  225. { Return the overall status of the image source `isrc'. The status is
  226. * particularly informative for incremental image sources, but may be used
  227. * by clients providing non-incremental data as well. }
  228. function CGImageSourceGetStatus( isrc: CGImageSourceRef ): CGImageSourceStatus; external name '_CGImageSourceGetStatus';
  229. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  230. { Return the current status of the image at `index' in the image source
  231. * `isrc'. The index is zero-based. The returned status is particularly
  232. * informative for incremental image sources but may used by clients
  233. * providing non-incremental data as well. }
  234. function CGImageSourceGetStatusAtIndex( isrc: CGImageSourceRef; index: size_t ): CGImageSourceStatus; external name '_CGImageSourceGetStatusAtIndex';
  235. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  236. end.