CGImageDestination.pas 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. {
  2. * ImageIO - CGImageDestination.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 CGImageDestination;
  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, CGDataConsumer, CGImage, CGImageSource;
  88. {$ALIGN POWER}
  89. type
  90. CGImageDestinationRef = ^SInt32; { an opaque 32-bit type }
  91. {* Properties which may be passed to "CGImageDestinationAddImage"
  92. ** or "CGImageDestinationAddImageFromSource" to effect the output.
  93. ** The values apply to a single image of an image destination. *}
  94. { The desired compression quality to use when writing to an image
  95. * destination. If present, the value of this key is a CFNumberRef
  96. * in the range 0.0 to 1.0. A value of 1.0 implies lossless
  97. * compression is desired if destination format supports it.
  98. * A value of 0.0 implies that that maximum compression is
  99. * desired. }
  100. var kCGImageDestinationLossyCompressionQuality: CFStringRef; external name '_kCGImageDestinationLossyCompressionQuality'; (* attribute const *)
  101. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  102. { The desired background color to composite against when writing
  103. * an image with alpha to a destination format that does not support
  104. * alpha. If present, the value of this key is a CGColorRef without
  105. * any alpha component of its own. If not present a white color
  106. * will be used if needed. }
  107. var kCGImageDestinationBackgroundColor: CFStringRef; external name '_kCGImageDestinationBackgroundColor'; (* attribute const *)
  108. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  109. { Return the CFTypeID for CGImageDestinations. }
  110. function CGImageDestinationGetTypeID: CFTypeID; external name '_CGImageDestinationGetTypeID';
  111. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  112. { Return an array of supported type identifiers. }
  113. function CGImageDestinationCopyTypeIdentifiers: CFArrayRef; external name '_CGImageDestinationCopyTypeIdentifiers';
  114. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  115. { Create an image destination writing to the data consumer `consumer'.
  116. * The parameter `type' specifies the type identifier of the resulting
  117. * image file. The parameter `count' specifies number of images (not
  118. * including thumbnails) that the image file will contain. The `options'
  119. * dictionary is reserved for future use; currently, you should pass NULL
  120. * for this parameter. }
  121. function CGImageDestinationCreateWithDataConsumer( consumer: CGDataConsumerRef; typ: CFStringRef; count: size_t; options: CFDictionaryRef ): CGImageDestinationRef; external name '_CGImageDestinationCreateWithDataConsumer';
  122. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  123. { Create an image destination writing to `data'. The parameter `type'
  124. * specifies the type identifier of the resulting image file. The
  125. * parameter `count' specifies number of images (not including thumbnails)
  126. * that the image file will contain. The `options' dictionary is reserved
  127. * for future use; currently, you should pass NULL for this parameter. }
  128. function CGImageDestinationCreateWithData( data: CFMutableDataRef; typ: CFStringRef; count: size_t; options: CFDictionaryRef ): CGImageDestinationRef; external name '_CGImageDestinationCreateWithData';
  129. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  130. { Create an image destination writing to `url'. The parameter `type'
  131. * specifies the type identifier of the resulting image file. The
  132. * parameter `count' specifies number of images (not including thumbnails)
  133. * that the image file will contain. The `options' dictionary is reserved
  134. * for future use; currently, you should pass NULL for this parameter.
  135. * Note that if `url' already exists, it will be overwritten. }
  136. function CGImageDestinationCreateWithURL( url: CFURLRef; typ: CFStringRef; count: size_t; options: CFDictionaryRef ): CGImageDestinationRef; external name '_CGImageDestinationCreateWithURL';
  137. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  138. { Specify the dictionary `properties' of properties which apply to all
  139. * images in the image destination `idst'. }
  140. procedure CGImageDestinationSetProperties( idst: CGImageDestinationRef; properties: CFDictionaryRef ); external name '_CGImageDestinationSetProperties';
  141. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  142. { Set the next image in the image destination `idst' to be `image' with
  143. * optional properties specified in `properties'. An error is logged if
  144. * more images are added than specified in the original count of the image
  145. * destination. }
  146. procedure CGImageDestinationAddImage( idst: CGImageDestinationRef; image: CGImageRef; properties: CFDictionaryRef ); external name '_CGImageDestinationAddImage';
  147. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  148. { Set the next image in the image destination `idst' to be the image at
  149. * `index' in the image source `isrc'. The index is zero-based. The
  150. * properties of the source image can be added to or overriden by supplying
  151. * additional keys/values in `properties'. If a key in `properties' has
  152. * the value kCFNull, the corresponding property in the destination will be
  153. * removed. }
  154. procedure CGImageDestinationAddImageFromSource( idst: CGImageDestinationRef; isrc: CGImageSourceRef; index: size_t; properties: CFDictionaryRef ); external name '_CGImageDestinationAddImageFromSource';
  155. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  156. { Write everything to the destination data, url or consumer of the image
  157. * destination `idst'. You must call this function or the image
  158. * destination will not be valid. After this function is called, no
  159. * additional data will be written to the image destination. Return true
  160. * if the image was successfully written; false otherwise. }
  161. function CGImageDestinationFinalize( idst: CGImageDestinationRef ): CBool; external name '_CGImageDestinationFinalize';
  162. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  163. end.