peachsim 0.1.1692 → 0.1.1700

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/cli/bridge-flow-runner.ts +61 -39
  2. package/cli/commands/agent-wrapper.ts +21 -10
  3. package/cli/commands/control.ts +27 -7
  4. package/cli/commands/coverage.ts +1 -1
  5. package/cli/commands/detect.ts +17 -4
  6. package/cli/commands/maestro-compare.ts +25 -99
  7. package/cli/help-core.ts +3 -4
  8. package/cli/maestro-compare.ts +172 -4
  9. package/cli/outbound-endpoints.ts +2 -10
  10. package/detox/index.ts +15 -0
  11. package/detox/launch-permissions.ts +169 -0
  12. package/dist-lib/agent-daemon-client.cjs +2 -2
  13. package/dist-lib/agent-events.cjs +2 -2
  14. package/dist-lib/attached-projects.cjs +2 -2
  15. package/dist-lib/auth/shared-session.cjs +2 -2
  16. package/dist-lib/backend-origin.cjs +2 -2
  17. package/dist-lib/beta.cjs +2 -2
  18. package/dist-lib/beta.mjs +1 -1
  19. package/dist-lib/bridge-constants.cjs +2 -2
  20. package/dist-lib/bridge-contract-input.cjs +2 -2
  21. package/dist-lib/bridge-contract-input.mjs +1 -1
  22. package/dist-lib/bridge-contract.cjs +2 -2
  23. package/dist-lib/bridge-contract.mjs +1 -1
  24. package/dist-lib/bundle-channel.cjs +18273 -15925
  25. package/dist-lib/capture-contract.cjs +2 -2
  26. package/dist-lib/capture-contract.mjs +1 -1
  27. package/dist-lib/cloud-contract.cjs +2 -2
  28. package/dist-lib/cloud-contract.mjs +1 -1
  29. package/dist-lib/cloud-test-args.cjs +2 -2
  30. package/dist-lib/cloud-test-args.mjs +1 -1
  31. package/dist-lib/cloud.cjs +2 -2
  32. package/dist-lib/cloud.mjs +1 -1
  33. package/dist-lib/config.cjs +2 -2
  34. package/dist-lib/config.mjs +1 -1
  35. package/dist-lib/detox/index.cjs +104 -3
  36. package/dist-lib/dev-bundle-resolution.cjs +208 -44
  37. package/dist-lib/expo-swift-bundle.cjs +2349 -1778
  38. package/dist-lib/expo-swift-metadata.cjs +2 -2
  39. package/dist-lib/expo-swift-metadata.mjs +1 -1
  40. package/dist-lib/home-paths.cjs +2 -2
  41. package/dist-lib/host/bridge-host.cjs +7885 -3334
  42. package/dist-lib/host/fetch-proxy-handler.cjs +331 -39
  43. package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
  44. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  45. package/dist-lib/host/replacement-module-handler.cjs +2 -2
  46. package/dist-lib/host/websocket-proxy.cjs +2 -2
  47. package/dist-lib/index.cjs +297 -77
  48. package/dist-lib/jump-to-source-babel.cjs +2 -2
  49. package/dist-lib/jump-to-source-native.cjs +2 -2
  50. package/dist-lib/kotlin-host.cjs +2 -2
  51. package/dist-lib/menu.cjs +2 -2
  52. package/dist-lib/menu.mjs +1 -1
  53. package/dist-lib/metro-fingerprint-registry.cjs +2 -2
  54. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  55. package/dist-lib/metro-production-bundle.cjs +2 -2
  56. package/dist-lib/metro-production-bundle.mjs +1 -1
  57. package/dist-lib/metro.cjs +294 -74
  58. package/dist-lib/native-app-identity-project.cjs +48 -37
  59. package/dist-lib/native-app-identity-project.mjs +47 -36
  60. package/dist-lib/native-app-identity.cjs +2 -2
  61. package/dist-lib/native-app-identity.mjs +1 -1
  62. package/dist-lib/native-firebase-metadata.cjs +2 -2
  63. package/dist-lib/native-firebase-metadata.mjs +1 -1
  64. package/dist-lib/plist.cjs +2 -2
  65. package/dist-lib/plist.mjs +1 -1
  66. package/dist-lib/profiles.cjs +2 -2
  67. package/dist-lib/public-brand.cjs +2 -2
  68. package/dist-lib/public-origins-lib-esm.json +24 -23
  69. package/dist-lib/public-origins-lib.json +199 -79
  70. package/dist-lib/react-native-host-modules.cjs +2 -2
  71. package/dist-lib/react-native-host-modules.mjs +1 -1
  72. package/dist-lib/reap-browser.cjs +2 -2
  73. package/dist-lib/scripts/dev-server-scanner.cjs +206 -31
  74. package/dist-lib/sdk.cjs +2 -2
  75. package/dist-lib/sdk.mjs +1 -1
  76. package/dist-lib/skills.cjs +19600 -15992
  77. package/dist-lib/swift-compile.cjs +640 -402
  78. package/dist-lib/swift-compile.mjs +595 -357
  79. package/dist-lib/swift-package.cjs +24 -20
  80. package/dist-lib/swift-package.mjs +23 -19
  81. package/dist-lib/swift-submit.cjs +2 -2
  82. package/dist-lib/swift-submit.mjs +1 -1
  83. package/dist-lib/swift-toolchain.cjs +31 -4
  84. package/dist-lib/swift.cjs +2 -2
  85. package/dist-lib/vite-swift.cjs +1559 -1208
  86. package/dist-lib/vite.cjs +251 -42
  87. package/dist-lib/worklet-executable.cjs +2 -2
  88. package/dist-lib/worklet-executable.mjs +1 -1
  89. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +1 -1
  90. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
  91. package/dist-types/packages/peach-engine/src/engine/scroll-pan-contacts.d.ts +3 -1
  92. package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +7 -0
  93. package/dist-types/packages/peach-engine/src/engine/types.d.ts +2 -1
  94. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
  95. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  96. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +1 -0
  97. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +17 -0
  98. package/dist-types/packages/peach-engine/src/render-worker/worker-input-runtime.d.ts +2 -1
  99. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +3 -0
  100. package/dist-types/packages/peach-globals/src/cameraBridgeContract.d.ts +1 -0
  101. package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +1 -0
  102. package/dist-types/packages/peach-globals/src/shellHostBridgeContract.d.ts +3 -0
  103. package/dist-types/packages/peach-kit/src/materials/types.d.ts +1 -0
  104. package/package.json +1 -1
  105. package/runtime-companion.json +1 -1
  106. package/scripts/dev-server-scanner.ts +4 -0
  107. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Alpha.h +2282 -0
  108. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/BasicImageTypes.h +55 -0
  109. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Conversion.h +10551 -6
  110. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Convolution.h +4236 -3
  111. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Geometry.h +827 -8
  112. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Histogram.h +1369 -0
  113. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Morphology.h +1243 -0
  114. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Transform.h +1747 -0
  115. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage.h +291 -2
  116. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_CVUtilities.h +1283 -0
  117. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Types.h +811 -91
  118. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Utilities.h +1342 -25
  119. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns.h +2738 -0
  120. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_constants.h +1685 -0
  121. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_graph.h +913 -0
  122. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_structures.h +1917 -0
  123. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/LinearAlgebra.h +23 -0
  124. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/arithmetic.h +209 -0
  125. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/base.h +104 -0
  126. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/linear_systems.h +77 -0
  127. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/matrix.h +554 -0
  128. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/norms.h +58 -0
  129. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/object.h +186 -0
  130. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/splat.h +86 -0
  131. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/vector.h +364 -0
  132. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Integration.h +195 -0
  133. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Quadrature.h +44 -0
  134. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/BLAS.h +2330 -0
  135. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/Types.h +123 -0
  136. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Solve.h +8339 -0
  137. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementation.h +520 -0
  138. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementationTyped.h +1893 -0
  139. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Sparse.h +10 -0
  140. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/blas_new.h +1098 -0
  141. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas.h +859 -0
  142. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas_new.h +1134 -0
  143. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h +10555 -0
  144. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h +695 -0
  145. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack.h +38526 -0
  146. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_types.h +60 -0
  147. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_version.h +20 -0
  148. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/thread_api.h +50 -0
  149. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBasicOps.h +1218 -0
  150. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBigNum.h +1458 -0
  151. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP.h +10377 -0
  152. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP_translate.h +167 -0
  153. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vForce.h +1243 -0
  154. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLib.h +114 -0
  155. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLibTypes.h +146 -0
  156. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vectorOps.h +1106 -0
  157. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vfp.h +294 -0
  158. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Headers/Accelerate.h +25 -1
  159. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFArray.h +673 -0
  160. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFAvailability.h +232 -0
  161. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h +827 -0
  162. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCalendar.h +121 -0
  163. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCharacterSet.h +387 -0
  164. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFData.h +79 -0
  165. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDate.h +122 -0
  166. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDictionary.h +674 -0
  167. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFError.h +182 -0
  168. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFLocale.h +213 -0
  169. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNotificationCenter.h +82 -0
  170. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNumber.h +129 -0
  171. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFSet.h +491 -0
  172. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h +883 -2
  173. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFTimeZone.h +98 -0
  174. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +11 -229
  175. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -6
  176. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +2 -1
  177. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h +1 -0
  178. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecBase.h +906 -3
  179. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecCertificate.h +613 -0
  180. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecItem.h +1284 -29
  181. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecPolicy.h +441 -0
  182. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecTrust.h +845 -0
  183. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/Security.h +4 -0
  184. package/sdk/ios/usr/include/AvailabilityMacros.h +3985 -0
  185. package/sdk/ios/usr/include/copyfile.h +143 -0
  186. package/sdk/ios/usr/include/malloc/_malloc.h +143 -0
  187. package/sdk/ios/usr/include/malloc/_malloc_type.h +153 -0
  188. package/sdk/ios/usr/include/malloc/_platform.h +80 -0
  189. package/sdk/ios/usr/include/malloc/_ptrcheck.h +43 -0
  190. package/sdk/ios/usr/include/malloc/malloc.h +768 -0
  191. package/sdk/ios/usr/include/os/availability.h +168 -6
  192. package/sdk/ios/usr/include/os/base.h +351 -0
  193. package/sdk/ios/usr/include/os/clock.h +18 -0
  194. package/sdk/ios/usr/include/os/lock.h +232 -10
  195. package/sdk/ios/usr/include/os/log.h +521 -38
  196. package/sdk/ios/usr/include/os/object.h +320 -3
  197. package/sdk/ios/usr/include/os/trace.h +492 -0
  198. package/sdk/ios/usr/include/os/trace_base.h +167 -0
  199. package/sdk/ios/usr/include/os/workgroup.h +37 -0
  200. package/sdk/ios/usr/include/os/workgroup_base.h +91 -0
  201. package/sdk/ios/usr/include/os/workgroup_interval.h +156 -0
  202. package/sdk/ios/usr/include/os/workgroup_object.h +359 -0
  203. package/sdk/ios/usr/include/os/workgroup_parallel.h +76 -0
  204. package/sdk/ios/usr/include/sys/cdefs.h +38 -0
  205. package/sdk/ios/wasm/include/unistd.h +3 -0
  206. package/skills/contrast/SKILL.md +3 -0
  207. package/src/codex-client.ts +11 -6
  208. package/src/dev-bundle-resolution.ts +124 -48
  209. package/src/expo-native-workspace.ts +176 -0
  210. package/src/expo-swift-host.ts +161 -26
  211. package/src/expo-swift-ready.ts +14 -28
  212. package/src/expoSwiftContract.ts +4 -1
  213. package/src/generated/swift-c-predefines.json +68 -12
  214. package/src/host/bridge-host.ts +5 -0
  215. package/src/installed-package-versions.ts +14 -1
  216. package/src/metro-project-root.ts +44 -33
  217. package/src/native-app-identity-project.ts +1 -0
  218. package/src/nitro-adapter.lock.json +916 -10
  219. package/src/nitro-adapter.ts +33 -24
  220. package/src/nitro-bundle.ts +108 -22
  221. package/src/nitro-compile.ts +32 -5
  222. package/src/nitro-source.ts +13 -3
  223. package/src/nitroAdapterContract.ts +100 -20
  224. package/src/node-http-fetch.ts +116 -0
  225. package/src/packageVersionsContract.ts +46 -0
  226. package/src/serverDiscoveryContract.ts +1 -0
  227. package/src/settingsContract.ts +0 -30
  228. package/src/swift-binary-modules.ts +20 -5
  229. package/src/swift-compile.ts +168 -48
  230. package/src/swift-coverage/xcode-assets.ts +4 -3
  231. package/src/swift-host.ts +14 -3
  232. package/src/swift-objc-compile.ts +32 -5
  233. package/src/swift-objc-metadata.ts +2 -2
  234. package/src/swift-objc-platform.ts +2 -2
  235. package/src/swift-objc-standin.ts +43 -13
  236. package/src/swift-package.ts +33 -26
  237. package/src/swift-source-pods.ts +126 -41
  238. package/src/swift-standin-digest.ts +77 -0
  239. package/src/swift-standin-emit.ts +40 -4
  240. package/src/swift-standins.ts +68 -19
  241. package/src/swift-toolchain.ts +38 -0
  242. package/src/swiftContract.ts +8 -0
  243. package/src/vite-plugin.ts +0 -10
  244. package/src/xcode-project.ts +62 -42
  245. package/src/settings-flags.ts +0 -107
@@ -0,0 +1,2282 @@
1
+ /*!
2
+ * @header Alpha.h
3
+ * vImage Framework
4
+ *
5
+ * @copyright Copyright (c) 2003-2016 by Apple Inc. All rights reserved.
6
+ *
7
+ * See vImage/vImage.h for more on how to better view the headerdoc documentation for functions declared herein.
8
+ *
9
+ * @discussion
10
+ * Alpha compositing is the practice of blending one image into another using a coverage component, commonly called
11
+ * alpha, to indicate how opaque each pixel is. A value of 1.0 (or 255 if an 8-bit image) indicates the
12
+ * pixel is fully opaque. A value of 0 indicates that it is fully transparent. Values in beetween establish a linear scale
13
+ * of partial opacity. Alpha can be used to slowly fade one image into another. Some images such as icons, have opqaue
14
+ * portions and transparent portions. A blending operation based on alpha is required to draw these over a background
15
+ * image.
16
+ *
17
+ * In its simplest form, an alpha blend is a linear interpolation between pixel of two images:
18
+ * <pre>@textblock
19
+ * float: new color = top color * alpha + (1-alpha) * bottom color
20
+ * 8-bit: new color = (top color * alpha + (255-alpha) * bottom color + 127) / 255
21
+ * @/textblock </pre>
22
+ * However, these formulations are a bit too simplistic because they do not account for the possibility that
23
+ * the bottom layer may have some transparency to it too. One subtlety of adding transparency to the bottom image
24
+ * is that the result image has an alpha component to it too that should be divided out:
25
+ * <pre>@textblock
26
+ * float: new alpha = top alpha + (1-top alpha) * bottom alpha
27
+ * float: new color = (top color * top alpha + (1- top alpha) * bottom color * bottom alpha ) / new alpha
28
+ *
29
+ * 8-bit: new alpha = top alpha + ((255-top alpha) * bottom alpha + 127)/255
30
+ * 8-bit: new color = (255 * top color * top alpha + (255- top alpha) * bottom color * bottom alpha + (255*255)/2) / (255 * 255 * new alpha)
31
+ * @/textblock </pre>
32
+ * As might be imagined, this extra complication may become costly. At the cost of a small amount of accuracy in non-opaque regions
33
+ * of the image, it is common to leave the alpha multiplied into the image. This avoids the division at the end. In addition,
34
+ * if the result is used in another blend, we don't have to multiply the alpha back in at that stage, which simplifies things
35
+ * all around. Such images with the alpha channel multiplied into the other channels are called pre-multiplied images.
36
+ *
37
+ * This gives us the following for premultiplied alpha blends:
38
+ * <pre>@textblock
39
+ * float: new alpha = top alpha + (1 - top alpha) * bottom alpha
40
+ * float: new premultiplied color = top premultiplied color + (1 - top alpha) * bottom premultiplied color
41
+ *
42
+ * 8-bit: new alpha = top alpha + ((255 - top alpha) * bottom alpha + 127)/255
43
+ * 8-bit: new premultiplied color = top premultiplied color + ((255 - top alpha) * bottom premultiplied color + 127)/255
44
+ * @/textblock </pre>
45
+ *
46
+ * Some images are known to be fully opaque. For such images, alpha is 1.0 (or 255) for all the pixels, and consequently
47
+ * do not require any computation to be done to interconvert between premultiplied and non-premultiplied states. That is,
48
+ * since x/1 = x and x*1 = x, they are non-premultiplied and premultiplied at the same time, and can serve in either
49
+ * capacity as needed. Because of this special status, CoreGraphics labels them kCGImageAlphaNoneSkipFirst/Last. vImage
50
+ * does similar things in vImage_Utilities.h. Labelling opaque buffers as such enables cheaper alpha blending and will frequently
51
+ * will let us avoid blending all-together as a simple copy operation will do.
52
+ *
53
+ * This header provides compositing (blending) operations for both premultiplied and non-premultiplied images, functions
54
+ * to premultiply or unpremultiply images, and some functions to make sure that the color channel values do not exceed
55
+ * the alpha value, which sometimes can happen after a convolution, morphological or resampling operation.
56
+ *
57
+ * These alpha compositing functions assume that the floating point range is 0.0 (black) to 1.0 (full intensity color).
58
+ * While values outside these ranges do function correctly (you can have 110% intensity color or -50% color, for example),
59
+ * the calculation is done assuming 1.0 represents full intensity color, and 0.0 represents the absence of color. If these
60
+ * assumptions are not correct, then the calculation will produce incorrect results. Apple does not currently provide
61
+ * alpha compositing functions that work with any floating point range in vImage.
62
+ *
63
+ * 8 bit functionality assumes that 0 is no color, and 255 is full color. 8 bit functions do saturated clipping before
64
+ * converting from internal precision back to 8 bits to make sure that modulo overflow does not occur. The internal
65
+ * calculation is done with higher precision.
66
+ *
67
+ * @ignorefuncmacro VIMAGE_NON_NULL
68
+ */
69
+
70
+ #ifndef VIMAGE_ALPHA_H
71
+ #define VIMAGE_ALPHA_H
72
+
73
+ #include <vImage/vImage_Types.h>
74
+
75
+ #ifdef __cplusplus
76
+ extern "C" {
77
+ #endif
78
+
79
+ /*!
80
+ * @functiongroup Alpha Blend
81
+ * @discussion The Alpha Blend functions composite two non-premultiplied images together to produce a non-premultiplied result.
82
+ * They are in general more expensive than their premultiplied counterparts, because the alpha has to be
83
+ * divided out of the result at the end.
84
+ */
85
+
86
+ /*!
87
+ * @function vImageAlphaBlend_Planar8
88
+ * @abstract Composite two non-premultiplied planar 8-bit images, to produce a non-premultiplied result.
89
+ * @discussion
90
+ *
91
+ * For each color channel:
92
+ * <pre>@textblock
93
+ * float destColor = ( srcTopColor * srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha * srcBottomColor ) / alpha
94
+ * @/textblock </pre>
95
+ * alpha (the new alpha value for that pixel) is calculated as:
96
+ * <pre>@textblock
97
+ * float alpha = srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha
98
+ * @/textblock </pre>
99
+ * For planar data, you need to calculate alpha yourself ahead of time and provide that as an argument to this function.
100
+ * This can be done using:
101
+ * <pre>@textblock
102
+ * vImagePremultipliedAlphaBlend_Planar8( srcTopAlpha, srcTopAlpha, srcBottomAlpha, alpha, kvImageNoFlags );
103
+ * @/textblock </pre>
104
+ * This function can work in place provided the following are true:
105
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
106
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
107
+ *
108
+ * The ARGB versions work for all 4 channel 8-bit / channel image formats with alpha first in memory.
109
+ *
110
+ * @param srcTop The color image that is composited on top of the bottom image
111
+ * @param srcTopAlpha The alpha channel corresponding to the srcTop image
112
+ * @param srcBottom The color image that is below the srcTop image, into which it is blended
113
+ * @param srcBottomAlpha The alpha channel corresponding to the srcBottom image
114
+ * @param alpha The alpha channel for the destination image. You need to calculate this ahead of time as:
115
+ * <pre>@textblock
116
+ * vImagePremultipliedAlphaBlend_Planar8( srcTopAlpha, srcTopAlpha, srcBottomAlpha, alpha, kvImageNoFlags );
117
+ * @/textblock </pre>
118
+ * @oaram dest The non-premultiplied result will be written here.
119
+ *
120
+ * @param flags The following flags are allowed:
121
+ * <pre>@textblock
122
+ * kvImageNoFlags Default operation
123
+ *
124
+ * kvImageDoNotTile Disables internal multithreading. This may be useful if you are writing your own multithreaded tiling engine.
125
+ * @/textblock</pre>
126
+ * @result The following result codes may be returned:
127
+ * <pre>@textblock
128
+ * kvImageNoError Success!
129
+ *
130
+ * kvImageRoiLargerThanInputBuffer The destination buffer must be no larger than srcTop, srcBottom, srcTopAlpha, srcBottomAlpha and alpha.
131
+ * @/textblock</pre>
132
+ */
133
+ VIMAGE_PF vImage_Error vImageAlphaBlend_Planar8( const vImage_Buffer *srcTop, const vImage_Buffer *srcTopAlpha, const vImage_Buffer *srcBottom, const vImage_Buffer *srcBottomAlpha, const vImage_Buffer *alpha, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3,4,5,6) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
134
+
135
+ /*!
136
+ * @function vImageAlphaBlend_PlanarF
137
+ * @abstract Composite two non-premultiplied planar floating-point images, to produce a non-premultiplied result.
138
+ * @discussion
139
+ *
140
+ * For each color channel:
141
+ * <pre>@textblock
142
+ * float destColor = ( srcTopColor * srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha * srcBottomColor ) / alpha
143
+ * @/textblock </pre>
144
+ * alpha (the new alpha value for that pixel) is calculated as:
145
+ * <pre>@textblock
146
+ * float alpha = srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha
147
+ * @/textblock </pre>
148
+ * For planar data, you need to calculate alpha yourself ahead of time and provide that as an argument to this function.
149
+ * This can be done using:
150
+ * <pre>@textblock
151
+ * vImagePremultipliedAlphaBlend_PlanarF( srcTopAlpha, srcTopAlpha, srcBottomAlpha, alpha, kvImageNoFlags );
152
+ * @/textblock </pre>
153
+ * This function can work in place provided the following are true:
154
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
155
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
156
+ *
157
+ * The ARGB versions work for all 4 channel 8-bit / channel image formats with alpha first in memory.
158
+ *
159
+ * @param srcTop The color image that is composited on top of the bottom image
160
+ * @param srcTopAlpha The alpha channel corresponding to the srcTop image
161
+ * @param srcBottom The color image that is below the srcTop image, into which it is blended
162
+ * @param srcBottomAlpha The alpha channel corresponding to the srcBottom image
163
+ * @param alpha The alpha channel for the destination image. You need to calculate this ahead of time as:
164
+ * <pre>@textblock
165
+ * vImagePremultipliedAlphaBlend_PlanarF( srcTopAlpha, srcTopAlpha, srcBottomAlpha, alpha, kvImageNoFlags );
166
+ * @/textblock </pre>
167
+ * @oaram dest The non-premultiplied result will be written here.
168
+ *
169
+ * @param flags The following flags are allowed:
170
+ * <pre>@textblock
171
+ * kvImageNoFlags Default operation
172
+ *
173
+ * kvImageDoNotTile Disables internal multithreading. This may be useful if you are writing your own multithreaded tiling engine.
174
+ * @/textblock</pre>
175
+ * @result The following result codes may be returned:
176
+ * <pre>@textblock
177
+ * kvImageNoError Success!
178
+ *
179
+ * kvImageRoiLargerThanInputBuffer The destination buffer must be no larger than srcTop, srcBottom, srcTopAlpha, srcBottomAlpha and alpha.
180
+ * @/textblock</pre>
181
+ */
182
+
183
+ VIMAGE_PF vImage_Error vImageAlphaBlend_PlanarF( const vImage_Buffer *srcTop, const vImage_Buffer *srcTopAlpha, const vImage_Buffer *srcBottom, const vImage_Buffer *srcBottomAlpha, const vImage_Buffer *alpha, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3,4,5,6) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
184
+
185
+ /*!
186
+ * @function vImageAlphaBlend_ARGB8888
187
+ * @abstract Composite two non-premultiplied ARGB8888 images, to produce a non-premultiplied result.
188
+ * @discussion
189
+ *
190
+ * For each color channel:
191
+ * <pre>@textblock
192
+ * float destColor = ( srcTopColor * srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha * srcBottomColor ) / alpha
193
+ * @/textblock </pre>
194
+ * alpha (the new alpha value for that pixel) is calculated as:
195
+ * <pre>@textblock
196
+ * float alpha = srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha
197
+ * @/textblock </pre>
198
+ *
199
+ * This function can work in place provided the following are true:
200
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
201
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
202
+ *
203
+ * The ARGB versions work for all 4 channel 8-bit / channel image formats with alpha first in memory.
204
+ *
205
+ * @param srcTop The image that is composited on top of the bottom image. The alpha channel must appear first.
206
+ * @param srcBottom The image that is below the srcTop image, into which it is blended. The alpha channel must appear first.
207
+ * @oaram dest The non-premultiplied result will be written here.
208
+ *
209
+ * @param flags The following flags are allowed:
210
+ * <pre>@textblock
211
+ * kvImageNoFlags Default operation
212
+ *
213
+ * kvImageDoNotTile Disables internal multithreading. This may be useful if you are writing your own multithreaded tiling engine.
214
+ * @/textblock</pre>
215
+ * @result The following result codes may be returned:
216
+ * <pre>@textblock
217
+ * kvImageNoError Success!
218
+ *
219
+ * kvImageRoiLargerThanInputBuffer The destination buffer must be no larger than srcTop, srcBottom, srcTopAlpha, srcBottomAlpha and alpha.
220
+ * @/textblock</pre>
221
+ */
222
+ VIMAGE_PF vImage_Error vImageAlphaBlend_ARGB8888( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
223
+
224
+ /*!
225
+ * @function vImageAlphaBlend_ARGBFFFF
226
+ * @abstract Composite two non-premultiplied ARGBFFFF images, to produce a non-premultiplied result.
227
+ * @discussion
228
+ *
229
+ * For each color channel:
230
+ * <pre>@textblock
231
+ * float destColor = ( srcTopColor * srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha * srcBottomColor ) / alpha
232
+ * @/textblock </pre>
233
+ * alpha (the new alpha value for that pixel) is calculated as:
234
+ * <pre>@textblock
235
+ * float alpha = srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha
236
+ * @/textblock </pre>
237
+ *
238
+ * This function can work in place provided the following are true:
239
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
240
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
241
+ *
242
+ * The ARGB versions work for all 4 channel float / channel image formats with alpha first in memory.
243
+ *
244
+ * @param srcTop The image that is composited on top of the bottom image. The alpha channel must appear first.
245
+ * @param srcBottom The image that is below the srcTop image, into which it is blended. The alpha channel must appear first.
246
+ * @oaram dest The non-premultiplied result will be written here.
247
+ *
248
+ * @param flags The following flags are allowed:
249
+ * <pre>@textblock
250
+ * kvImageNoFlags Default operation
251
+ *
252
+ * kvImageDoNotTile Disables internal multithreading. This may be useful if you are writing your own multithreaded tiling engine.
253
+ * @/textblock</pre>
254
+ * @result The following result codes may be returned:
255
+ * <pre>@textblock
256
+ * kvImageNoError Success!
257
+ *
258
+ * kvImageRoiLargerThanInputBuffer The destination buffer must be no larger than srcTop, srcBottom, srcTopAlpha, srcBottomAlpha and alpha.
259
+ * @/textblock</pre>
260
+ */
261
+ VIMAGE_PF vImage_Error vImageAlphaBlend_ARGBFFFF( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
262
+
263
+ /*!
264
+ * @functiongroup Alpha Blend (Premultiplied)
265
+ * @discussion Premultiplied alpha blends composite two premultiplied images to produce a premultiplied result.
266
+ */
267
+
268
+ /*!
269
+ * @function vImagePremultipliedAlphaBlend_Planar8
270
+ * @abstract blend two premultiplied Planar8 images to produce a premultiplied Planar8 result.
271
+ * @discussion
272
+ * For each color channel:
273
+ * <pre>@textblock
274
+ * uint8_t destColor = srcTopColor + ((255 - srcTopAlpha) * srcBottomColor + 127)/255;
275
+ * @/textblock</pre>
276
+ * Similarly, the output alpha channel (the new alpha value for that pixel) can be calculated as:
277
+ * <pre>@textblock
278
+ * uint8_t alpha = srcTopAlpha + ((255 - srcTopAlpha) * srcBottomAlpha + 127)/255;
279
+ * @/textblock</pre>
280
+ * The alpha values are presumed to be normalized over the range [0, 255].
281
+ *
282
+ * This function can work in place provided the following are true:
283
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
284
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
285
+ *
286
+ * @param srcTop The top image
287
+ * @param srcTopAlpha The coverage component for the top image (alpha)
288
+ * @param srcBottom The bottom image
289
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
290
+ * <pre>@textblock
291
+ * kvImageNoFlags Default operation
292
+ *
293
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
294
+ * this in the context of your own multithreaded tiling engine.
295
+ * @/textblock </pre>
296
+ *
297
+ * @result The following error codes may occur:
298
+ * <pre>@textblock
299
+ * kvImageNoError Success.
300
+ *
301
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
302
+ * @/textblock</pre>
303
+ *
304
+ */
305
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlend_Planar8( const vImage_Buffer *srcTop,
306
+ const vImage_Buffer *srcTopAlpha,
307
+ const vImage_Buffer *srcBottom,
308
+ const vImage_Buffer *dest,
309
+ vImage_Flags flags )
310
+ VIMAGE_NON_NULL(1,2,3,4)
311
+ API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
312
+
313
+ /*!
314
+ * @function vImagePremultipliedAlphaBlend_PlanarF
315
+ * @abstract blend two premultiplied PlanarF images to produce a premultiplied PlanarF result.
316
+ * @discussion
317
+ * For each color channel:
318
+ * <pre>@textblock
319
+ * float destColor = srcTopColor + (1.0 - srcTopAlpha) * srcBottomColor;
320
+ * @/textblock</pre>
321
+ * Similarly, the output alpha channel (the new alpha value for that pixel) can be calculated as:
322
+ * <pre>@textblock
323
+ * float alpha = srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha
324
+ * @/textblock</pre>
325
+ * The alpha values are presumed to be normalized over the range [0.0f, 1.0f].
326
+ *
327
+ * This function can work in place provided the following are true:
328
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
329
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
330
+ *
331
+ * @param srcTop The top image
332
+ * @param srcTopAlpha The coverage component for the top image (alpha)
333
+ * @param srcBottom The bottom image
334
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
335
+ * <pre>@textblock
336
+ * kvImageNoFlags Default operation
337
+ *
338
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
339
+ * this in the context of your own multithreaded tiling engine.
340
+ * @/textblock </pre>
341
+ *
342
+ * @result The following error codes may occur:
343
+ * <pre>@textblock
344
+ * kvImageNoError Success.
345
+ *
346
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
347
+ * @/textblock</pre>
348
+ *
349
+ */
350
+
351
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlend_PlanarF( const vImage_Buffer *srcTop,
352
+ const vImage_Buffer *srcTopAlpha,
353
+ const vImage_Buffer *srcBottom,
354
+ const vImage_Buffer *dest,
355
+ vImage_Flags flags )
356
+ VIMAGE_NON_NULL(1,2,3,4)
357
+ API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
358
+
359
+ /*!
360
+ * @function vImagePremultipliedAlphaBlend_ARGB8888
361
+ * @abstract blend two premultiplied ARGB8888 images to produce a premultiplied ARGB8888 result.
362
+ * @discussion
363
+ * For each color channel:
364
+ * <pre>@textblock
365
+ * uint8_t destColor = srcTopColor + ((255 - srcTopAlpha) * srcBottomColor + 127)/255;
366
+ * @/textblock</pre>
367
+ * Similarly, the output alpha channel (the new alpha value for that pixel) can be calculated as:
368
+ * <pre>@textblock
369
+ * uint8_t alpha = srcTopAlpha + ((255 - srcTopAlpha) * srcBottomAlpha + 127)/255;
370
+ * @/textblock</pre>
371
+ * The alpha values are presumed to be normalized over the range [0, 255].
372
+ *
373
+ * This function can work in place provided the following are true:
374
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
375
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
376
+ *
377
+ * The function will work for all 4 channel 8-bit / channel image formats with alpha first in memory, not just ARGB.
378
+ *
379
+ * @param srcTop The top image
380
+ * @param srcBottom The bottom image
381
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
382
+ * @param flags The following flags may be used:
383
+ * <pre>@textblock
384
+ * kvImageNoFlags Default operation
385
+ *
386
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
387
+ * this in the context of your own multithreaded tiling engine.
388
+ * @/textblock </pre>
389
+ *
390
+ * @result The following error codes may occur:
391
+ * <pre>@textblock
392
+ * kvImageNoError Success.
393
+ *
394
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
395
+ * @/textblock</pre>
396
+ *
397
+ */
398
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlend_ARGB8888( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
399
+
400
+ /*!
401
+ * @function vImagePremultipliedAlphaBlend_BGRA8888
402
+ * @abstract blend two premultiplied BGRA8888 images to produce a premultiplied BGRA8888 result.
403
+ * @discussion
404
+ * For each color channel:
405
+ * <pre>@textblock
406
+ * uint8_t destColor = srcTopColor + ((255 - srcTopAlpha) * srcBottomColor + 127)/255;
407
+ * @/textblock</pre>
408
+ * Similarly, the output alpha channel (the new alpha value for that pixel) can be calculated as:
409
+ * <pre>@textblock
410
+ * uint8_t alpha = srcTopAlpha + ((255 - srcTopAlpha) * srcBottomAlpha + 127)/255;
411
+ * @/textblock</pre>
412
+ * The alpha values are presumed to be normalized over the range [0, 255].
413
+ *
414
+ * This function can work in place provided the following are true:
415
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
416
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
417
+ *
418
+ * The function will work for all 4 channel 8-bit / channel image formats with alpha last in memory, not just BGRA.
419
+ * Also available as vImagePremultipliedAlphaBlend_RGBA8888().
420
+ *
421
+ * @param srcTop The top image
422
+ * @param srcBottom The bottom image
423
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
424
+ * @param flags The following flags may be used:
425
+ * <pre>@textblock
426
+ * kvImageNoFlags Default operation
427
+ *
428
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
429
+ * this in the context of your own multithreaded tiling engine.
430
+ * @/textblock </pre>
431
+ *
432
+ * @result The following error codes may occur:
433
+ * <pre>@textblock
434
+ * kvImageNoError Success.
435
+ *
436
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
437
+ * @/textblock</pre>
438
+ *
439
+ */
440
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlend_BGRA8888( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.6), ios(5.0), watchos(1.0), tvos(5.0));
441
+ #define vImagePremultipliedAlphaBlend_RGBA8888( _srcTop, _srcBottom, _dest, _flags ) vImagePremultipliedAlphaBlend_BGRA8888((_srcTop), (_srcBottom), (_dest), (_flags))
442
+
443
+ /*!
444
+ * @function vImagePremultipliedAlphaBlend_ARGBFFFF
445
+ * @abstract blend two premultiplied ARGBFFFF images to produce a premultiplied ARGBFFFF result.
446
+ * @discussion
447
+ * <pre>@textblock
448
+ * float destColor = srcTopColor + (1.0 - srcTopAlpha) * srcBottomColor;
449
+ * @/textblock</pre>
450
+ * Similarly, the output alpha channel (the new alpha value for that pixel) can be calculated as:
451
+ * <pre>@textblock
452
+ * float alpha = srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha
453
+ * @/textblock</pre>
454
+ * The alpha values are presumed to be normalized over the range [0.0f, 1.0f].
455
+ *
456
+ * This function can work in place provided the following are true:
457
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
458
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
459
+ *
460
+ * The function will work for all 4 channel float / channel image formats with alpha first in memory, not just ARGB.
461
+ *
462
+ * @param srcTop The top image
463
+ * @param srcBottom The bottom image
464
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
465
+ * @param flags The following flags may be used:
466
+ * <pre>@textblock
467
+ * kvImageNoFlags Default operation
468
+ *
469
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
470
+ * this in the context of your own multithreaded tiling engine.
471
+ * @/textblock </pre>
472
+ *
473
+ * @result The following error codes may occur:
474
+ * <pre>@textblock
475
+ * kvImageNoError Success.
476
+ *
477
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
478
+ * @/textblock</pre>
479
+ *
480
+ */
481
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlend_ARGBFFFF( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
482
+
483
+ /*!
484
+ * @function vImagePremultipliedAlphaBlend_BGRAFFFF
485
+ * @abstract blend two premultiplied ARGBFFFF images to produce a premultiplied BGRAFFFF result.
486
+ * @discussion
487
+ * <pre>@textblock
488
+ * float destColor = srcTopColor + (1.0 - srcTopAlpha) * srcBottomColor;
489
+ * @/textblock</pre>
490
+ * Similarly, the output alpha channel (the new alpha value for that pixel) can be calculated as:
491
+ * <pre>@textblock
492
+ * float alpha = srcTopAlpha + (1.0 - srcTopAlpha) * srcBottomAlpha
493
+ * @/textblock</pre>
494
+ * The alpha values are presumed to be normalized over the range [0.0f, 1.0f].
495
+ *
496
+ * This function can work in place provided the following are true:
497
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
498
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
499
+ *
500
+ * The function will work for all 4 channel float / channel image formats with alpha first in memory, not just BGRA.
501
+ * Also available as vImagePremultipliedAlphaBlend_RGBAFFFF.
502
+ *
503
+ * @param srcTop The top image
504
+ * @param srcBottom The bottom image
505
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
506
+ * @param flags The following flags may be used:
507
+ * <pre>@textblock
508
+ * kvImageNoFlags Default operation
509
+ *
510
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
511
+ * this in the context of your own multithreaded tiling engine.
512
+ * @/textblock </pre>
513
+ *
514
+ * @result The following error codes may occur:
515
+ * <pre>@textblock
516
+ * kvImageNoError Success.
517
+ *
518
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
519
+ * @/textblock</pre>
520
+ *
521
+ */
522
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlend_BGRAFFFF( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.6), ios(5.0), watchos(1.0), tvos(5.0));
523
+ #define vImagePremultipliedAlphaBlend_RGBAFFFF( _srcTop, _srcBottom, _dest, _flags ) vImagePremultipliedAlphaBlend_BGRAFFFF((_srcTop), (_srcBottom), (_dest), (_flags))
524
+
525
+ /*!
526
+ * @function vImagePremultipliedAlphaBlendWithPermute_ARGB8888
527
+ * @abstract Reorder the channels of the top 8-bit 4 channel premultiplied image, blend into a bottom premultiplied ARGB8888 image.
528
+ * @discussion
529
+ * This function does 3 things.
530
+ * <pre>@textblock
531
+ * 1. Changes the order of channels of srcTop according to permuteMap.
532
+ * 2. A premultiplied alpha compositing.
533
+ * 3. Set destA to 0xFF when makeDestAlphaOpaque is true.
534
+ *
535
+ * permuteMap[i] = 0, 1, 2, or 3 to specify how we permute each channel in srcTop.
536
+ *
537
+ * permuteMap[0] tells which channel in srcTop XXXX8888 will be used as A.
538
+ * permuteMap[1] tells which channel in srcTop XXXX8888 will be used as R.
539
+ * permuteMap[2] tells which channel in srcTop XXXX8888 will be used as G.
540
+ * permuteMap[3] tells which channel in srcTop XXXX8888 will be used as B.
541
+ * @/textblock</pre>
542
+ *
543
+ * This permuteMap lets us to cover any channel order for the top and bottom images.
544
+ * For example,
545
+ * <pre>@textblock
546
+ * PremultipliedAlphaBlend(srcTop_ARGB8888, srcBottom_ARGB8888) -> dest_ARGB8888
547
+ * will be covered by permuteMap[4] = {0, 1, 2, 3}
548
+ *
549
+ * PremultipliedAlphaBlend(srcTop_RGBA8888, srcBottom_ARGB8888) -> dest_ARGB8888
550
+ * will be covered by permuteMap[4] = {3, 0, 1, 2}
551
+ *
552
+ * PremultipliedAlphaBlend(srcTop_ABGR8888, srcBottom_ARGB8888) -> dest_ARGB8888
553
+ * will be covered by permuteMap[4] = {0, 3, 2, 1}
554
+ *
555
+ * PremultipliedAlphaBlend(srcTop_BGRA8888, srcBottom_ARGB8888) -> dest_ARGB8888
556
+ * will be covered by permuteMap[4] = {3, 2, 1, 0}
557
+ * @/textblock</pre>
558
+ *
559
+ * srcBottom will have the same pixel format (ARGB8888) as dest.
560
+ *
561
+ *
562
+ * The per-pixel operation is:
563
+ *
564
+ * <pre>@textblock
565
+ * uint8_t *srcTop, *srcBottom, *dest;
566
+ * uint8_t srcTopA, srcTopR, srcTopG, srcTopB;
567
+ * uint8_t srcBottomA, srcBottomR, srcBottomG, srcBottomB;
568
+ * uint8_t destA, destR, destG, destB;
569
+ *
570
+ * srcTopA = srcTop[ permuteMap[0] ];
571
+ * srcTopR = srcTop[ permuteMap[1] ];
572
+ * srcTopG = srcTop[ permuteMap[2] ];
573
+ * srcTopB = srcTop[ permuteMap[3] ];
574
+ *
575
+ * srcBottomA = srcBottom[ 0 ];
576
+ * srcBottomR = srcBottom[ 1 ];
577
+ * srcBottomG = srcBottom[ 2 ];
578
+ * srcBottomB = srcBottom[ 3 ];
579
+ *
580
+ * destR = (srcTopR * 255 + (255 - srcTopA) * srcBottomR + 127) / 255;
581
+ * destG = (srcTopG * 255 + (255 - srcTopA) * srcBottomG + 127) / 255;
582
+ * destB = (srcTopB * 255 + (255 - srcTopA) * srcBottomB + 127) / 255;
583
+ *
584
+ * if(makeDestAlphaOpaque)
585
+ * {
586
+ *
587
+ * dest[0] = 0xFF;
588
+ * dest[1] = destR;
589
+ * dest[2] = destG;
590
+ * dest[3] = destB;
591
+ * }
592
+ * else
593
+ * {
594
+ * destA = (srcTopA * 255 + (255 - srcTopA) * srcBottomA + 127) / 255;
595
+ *
596
+ * dest[0] = destA;
597
+ * dest[1] = destR;
598
+ * dest[2] = destG;
599
+ * dest[3] = destB;
600
+ * }
601
+ * @/textblock</pre>
602
+ *
603
+ * This function can work in place.
604
+ *
605
+ * @param srcTop A pointer to vImage_Buffer that references 8-bit XXXX interleaved source top image.
606
+ * @param srcBottom A pointer to vImage_Buffer that references 8-bit ARGB interleaved source bottom image.
607
+ * @param dest A pointer to vImage_Buffer that references 8-bit ARGB interleaved destination image.
608
+ * @param permuteMap Values that can be used to switch the channel order of the source top image.
609
+ * @param makeDestAlphaOpaque A boolean to set destA into 0xFF when it's true.
610
+ * @param flags The following flags are allowed:
611
+ * <pre>@textblock
612
+ * kvImageGetTempBufferSize Returns 0. Does no work.
613
+ * kvImageDoNotTile Disables internal multithreading, if any.
614
+ * @/textblock</pre>
615
+ * @return The following error codes may be returned:
616
+ * <pre>@textblock
617
+ * kvImageNoError Is returned when there was no error.
618
+ * kvImageRoiLargerThanInputBuffer The destination buffers are larger than the source buffer.
619
+ * kvImageBufferSizeMismatch Is returned when there is a mismatch in width & height of srcTop and srcBottom.
620
+ * kvImageUnknownFlagsBit Is returned when there is a unknown flag.
621
+ * kvImageInvalidParameter Is returned when the values in permuteMap[i] is not one of 0, 1, 2, or 3.
622
+ * @/textblock</pre>
623
+ *
624
+ */
625
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlendWithPermute_ARGB8888(const vImage_Buffer *srcTop,
626
+ const vImage_Buffer *srcBottom,
627
+ const vImage_Buffer *dest,
628
+ const uint8_t permuteMap[4],
629
+ bool makeDestAlphaOpaque,
630
+ vImage_Flags flags )
631
+ VIMAGE_NON_NULL(1,2,3,4)
632
+ API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
633
+
634
+
635
+
636
+ /*!
637
+ * @function vImagePremultipliedAlphaBlendWithPermute_RGBA8888
638
+ * @abstract Reorder the channels of the top 8-bit 4 channel premultiplied image, blend into a bottom premultiplied RGBA8888 image.
639
+ * @discussion
640
+ * This function does 3 things.
641
+ * <pre>@textblock
642
+ * 1. Changes the order of channels of srcTop according to permuteMap.
643
+ * 2. A premultiplied alpha compositing.
644
+ * 3. Set destA to 0xFF when makeDestAlphaOpaque is true.
645
+ *
646
+ * permuteMap[i] = 0, 1, 2, or 3 to specify how we permute each channel in srcTop.
647
+ *
648
+ * permuteMap[0] tells which channel in srcTop XXXX8888 will be used as A.
649
+ * permuteMap[1] tells which channel in srcTop XXXX8888 will be used as R.
650
+ * permuteMap[2] tells which channel in srcTop XXXX8888 will be used as G.
651
+ * permuteMap[3] tells which channel in srcTop XXXX8888 will be used as B.
652
+ * @/textblock</pre>
653
+ *
654
+ * This permuteMap lets us to cover any channel order for the top and bottom images.
655
+ * For example,
656
+ * <pre>@textblock
657
+ * PremultipliedAlphaBlend(srcTop_RGBA8888, srcBottom_RGBA8888) -> dest_RGBA8888
658
+ * will be covered by permuteMap[4] = {0, 1, 2, 3}
659
+ *
660
+ * PremultipliedAlphaBlend(srcTop_ARGB8888, srcBottom_RGBA8888) -> dest_RGBA8888
661
+ * will be covered by permuteMap[4] = {1, 2, 3, 0}
662
+ *
663
+ * PremultipliedAlphaBlend(srcTop_ABGR8888, srcBottom_RGBA8888) -> dest_RGBA8888
664
+ * will be covered by permuteMap[4] = {3, 2, 1, 0}
665
+ *
666
+ * PremultipliedAlphaBlend(srcTop_BGRA8888, srcBottom_RGBA8888) -> dest_RGBA8888
667
+ * will be covered by permuteMap[4] = {2, 1, 0, 3}
668
+ * @/textblock</pre>
669
+ *
670
+ * srcBottom will have the same pixel format (RGBA8888) as dest.
671
+ *
672
+ *
673
+ * The per-pixel operation is:
674
+ *
675
+ * <pre>@textblock
676
+ * uint8_t *srcTop, *srcBottom, *dest;
677
+ * uint8_t srcTopA, srcTopR, srcTopG, srcTopB;
678
+ * uint8_t srcBottomA, srcBottomR, srcBottomG, srcBottomB;
679
+ * uint8_t destA, destR, destG, destB;
680
+ *
681
+ * srcTopR = srcTop[ permuteMap[0] ];
682
+ * srcTopG = srcTop[ permuteMap[1] ];
683
+ * srcTopB = srcTop[ permuteMap[2] ];
684
+ * srcTopA = srcTop[ permuteMap[3] ];
685
+ *
686
+ * srcBottomR = srcBottom[ 0 ];
687
+ * srcBottomG = srcBottom[ 1 ];
688
+ * srcBottomB = srcBottom[ 2 ];
689
+ * srcBottomA = srcBottom[ 3 ];
690
+ *
691
+ * destR = (srcTopR * 255 + (255 - srcTopA) * srcBottomR + 127) / 255;
692
+ * destG = (srcTopG * 255 + (255 - srcTopA) * srcBottomG + 127) / 255;
693
+ * destB = (srcTopB * 255 + (255 - srcTopA) * srcBottomB + 127) / 255;
694
+ *
695
+ * if(makeDestAlphaOpaque)
696
+ * {
697
+ *
698
+ * dest[0] = 0xFF;
699
+ * dest[1] = destR;
700
+ * dest[2] = destG;
701
+ * dest[3] = destB;
702
+ * }
703
+ * else
704
+ * {
705
+ * destA = (srcTopA * 255 + (255 - srcTopA) * srcBottomA + 127) / 255;
706
+ *
707
+ * dest[0] = destA;
708
+ * dest[1] = destR;
709
+ * dest[2] = destG;
710
+ * dest[3] = destB;
711
+ * }
712
+ * @/textblock</pre>
713
+ *
714
+ * This function can work in place.
715
+ *
716
+ * @param srcTop A pointer to vImage_Buffer that references 8-bit XXXX interleaved source top image.
717
+ * @param srcBottom A pointer to vImage_Buffer that references 8-bit RGBA interleaved source bottom image.
718
+ * @param dest A pointer to vImage_Buffer that references 8-bit RGBA interleaved destination image.
719
+ * @param permuteMap Values that can be used to switch the channel order of the source top image.
720
+ * @param makeDestAlphaOpaque A boolean to set destA into 0xFF when it's true.
721
+ * @param flags The following flags are allowed:
722
+ * <pre>@textblock
723
+ * kvImageGetTempBufferSize Returns 0. Does no work.
724
+ * kvImageDoNotTile Disables internal multithreading, if any.
725
+ * @/textblock</pre>
726
+ * @return The following error codes may be returned:
727
+ * <pre>@textblock
728
+ * kvImageNoError Is returned when there was no error.
729
+ * kvImageRoiLargerThanInputBuffer The destination buffers are larger than the source buffer.
730
+ * kvImageBufferSizeMismatch Is returned when there is a mismatch in width & height of srcTop and srcBottom.
731
+ * kvImageUnknownFlagsBit Is returned when there is a unknown flag.
732
+ * kvImageInvalidParameter Is returned when the values in permuteMap[i] is not one of 0, 1, 2, or 3.
733
+ * @/textblock</pre>
734
+ *
735
+ */
736
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlendWithPermute_RGBA8888(const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, const uint8_t permuteMap[4], bool makeDestAlphaOpaque, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3,4) API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
737
+
738
+
739
+ /*!
740
+ * @functiongroup Alpha Blend (Premultiplied, other blend modes)
741
+ * @discussion These alternative blend modes correspond to the blend modes required for SVG
742
+ * (http://www.w3.org/TR/SVG/filters.html, see feBlend)
743
+ */
744
+
745
+ /*!
746
+ * @function vImagePremultipliedAlphaBlendMultiply_RGBA8888
747
+ * @abstract blend two premultiplied RGBA8888 images using the Multiply blend mode to produce a premultiplied RGBA8888 result.
748
+ * @discussion
749
+ * For each color channel:
750
+ * <pre>@textblock
751
+ * uint8_t destColor =((255 - srcTopAlpha) * srcBottomColor +
752
+ * (255 - srcBottomAlpha) * srcTopColor +
753
+ * srcTopColor * srcBottomColor + 127)/255;
754
+ * @/textblock</pre>
755
+ * The output alpha channel (the new alpha value for that pixel) can be calculated as:
756
+ * <pre>@textblock
757
+ * uint8_t alpha = srcTopAlpha + ((255 - srcTopAlpha) * srcBottomAlpha + 127)/255;
758
+ * @/textblock</pre>
759
+ * The alpha values are presumed to be normalized over the range [0, 255].
760
+ *
761
+ * This function can work in place provided the following are true:
762
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
763
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
764
+ *
765
+ * The function will work for all 4 channel 8-bit / channel image formats with alpha last in memory, not just RGBA.
766
+ * This function corresponds to the multiply blend mode in feBlend in the SVG standard. http://www.w3.org/TR/SVG/filters.html)
767
+ *
768
+ * @param srcTop The top image
769
+ * @param srcBottom The bottom image
770
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
771
+ * @param flags The following flags may be used:
772
+ * <pre>@textblock
773
+ * kvImageNoFlags Default operation
774
+ *
775
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
776
+ * this in the context of your own multithreaded tiling engine.
777
+ * @/textblock </pre>
778
+ *
779
+ * @result The following error codes may occur:
780
+ * <pre>@textblock
781
+ * kvImageNoError Success.
782
+ *
783
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
784
+ * @/textblock</pre>
785
+ *
786
+ */
787
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlendMultiply_RGBA8888( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0));
788
+
789
+ /*!
790
+ * @function vImagePremultipliedAlphaBlendScreen_RGBA8888
791
+ * @abstract blend two premultiplied RGBA8888 images using the Screen blend mode to produce a premultiplied RGBA8888 result.
792
+ * @discussion
793
+ * For each color channel:
794
+ * <pre>@textblock
795
+ * uint8_t destColor = CLAMP( srcTopColor + srcBottomcolor - (srcTopColor * srcBottomColor + 127)/255, 0, 255);
796
+ * @/textblock</pre>
797
+ * The output alpha channel (the new alpha value for that pixel) can be calculated as:
798
+ * <pre>@textblock
799
+ * uint8_t alpha = srcTopAlpha + ((255 - srcTopAlpha) * srcBottomAlpha + 127)/255;
800
+ * @/textblock</pre>
801
+ * The alpha values are presumed to be normalized over the range [0, 255].
802
+ *
803
+ * This function can work in place provided the following are true:
804
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
805
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
806
+ *
807
+ * The function will work for all 4 channel 8-bit / channel image formats with alpha last in memory, not just RGBA.
808
+ * This function corresponds to the screen blend mode in feBlend in the SVG standard. http://www.w3.org/TR/SVG/filters.html)
809
+ *
810
+ * @param srcTop The top image
811
+ * @param srcBottom The bottom image
812
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
813
+ * @param flags The following flags may be used:
814
+ * <pre>@textblock
815
+ * kvImageNoFlags Default operation
816
+ *
817
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
818
+ * this in the context of your own multithreaded tiling engine.
819
+ * @/textblock </pre>
820
+ *
821
+ * @result The following error codes may occur:
822
+ * <pre>@textblock
823
+ * kvImageNoError Success.
824
+ *
825
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
826
+ * @/textblock</pre>
827
+ *
828
+ */
829
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlendScreen_RGBA8888( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0));
830
+
831
+ /*!
832
+ * @function vImagePremultipliedAlphaBlendDarken_RGBA8888
833
+ * @abstract blend two premultiplied RGBA8888 images using the Darken blend mode to produce a premultiplied RGBA8888 result.
834
+ * @discussion
835
+ * For each color channel:
836
+ * <pre>@textblock
837
+ * uint8_t destColor = MIN( topColor + ((255 - srcTopAlpha) * srcBotomColor + 127) / 255,
838
+ * bottomColor + ((255 - srcBottomAlpha) * srcTopColor + 127) / 255);
839
+ * @/textblock</pre>
840
+ * The output alpha channel (the new alpha value for that pixel) can be calculated as:
841
+ * <pre>@textblock
842
+ * uint8_t alpha = srcTopAlpha + ((255 - srcTopAlpha) * srcBottomAlpha + 127)/255;
843
+ * @/textblock</pre>
844
+ * The alpha values are presumed to be normalized over the range [0, 255].
845
+ *
846
+ * This function can work in place provided the following are true:
847
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
848
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
849
+ *
850
+ * The function will work for all 4 channel 8-bit / channel image formats with alpha last in memory, not just RGBA.
851
+ * This function corresponds to the darken blend mode in feBlend in the SVG standard. http://www.w3.org/TR/SVG/filters.html)
852
+ *
853
+ * @param srcTop The top image
854
+ * @param srcBottom The bottom image
855
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
856
+ * @param flags The following flags may be used:
857
+ * <pre>@textblock
858
+ * kvImageNoFlags Default operation
859
+ *
860
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
861
+ * this in the context of your own multithreaded tiling engine.
862
+ * @/textblock </pre>
863
+ *
864
+ * @result The following error codes may occur:
865
+ * <pre>@textblock
866
+ * kvImageNoError Success.
867
+ *
868
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
869
+ * @/textblock</pre>
870
+ *
871
+ */
872
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlendDarken_RGBA8888( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0));
873
+
874
+ /*!
875
+ * @function vImagePremultipliedAlphaBlendLighten_RGBA8888
876
+ * @abstract blend two premultiplied RGBA8888 images using the Lighten blend mode to produce a premultiplied RGBA8888 result.
877
+ * @discussion
878
+ * For each color channel:
879
+ * <pre>@textblock
880
+ * uint8_t destColor = MAX( topColor + ((255 - srcTopAlpha) * srcBotomColor + 127) / 255,
881
+ * bottomColor + ((255 - srcBottomAlpha) * srcTopColor + 127) / 255);
882
+ * @/textblock</pre>
883
+ * The output alpha channel (the new alpha value for that pixel) can be calculated as:
884
+ * <pre>@textblock
885
+ * uint8_t alpha = srcTopAlpha + ((255 - srcTopAlpha) * srcBottomAlpha + 127)/255;
886
+ * @/textblock</pre>
887
+ * The alpha values are presumed to be normalized over the range [0, 255].
888
+ *
889
+ * This function can work in place provided the following are true:
890
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
891
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
892
+ *
893
+ * The function will work for all 4 channel 8-bit / channel image formats with alpha last in memory, not just RGBA.
894
+ * This function corresponds to the lighten blend mode in feBlend in the SVG standard. http://www.w3.org/TR/SVG/filters.html)
895
+ *
896
+ * @param srcTop The top image
897
+ * @param srcBottom The bottom image
898
+ * @param dest The result image is written here. This buffer must be preallocated before the function is called.
899
+ * @param flags The following flags may be used:
900
+ * <pre>@textblock
901
+ * kvImageNoFlags Default operation
902
+ *
903
+ * kvImageDoNotTile Disable internal multithreading. You might want to do that if you are calling
904
+ * this in the context of your own multithreaded tiling engine.
905
+ * @/textblock </pre>
906
+ *
907
+ * @result The following error codes may occur:
908
+ * <pre>@textblock
909
+ * kvImageNoError Success.
910
+ *
911
+ * kvImageRoiLargerThanInputBuffer The height and width of the result must be less than or equal to each of the input buffers.
912
+ * @/textblock</pre>
913
+ */
914
+ VIMAGE_PF vImage_Error vImagePremultipliedAlphaBlendLighten_RGBA8888( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0));
915
+
916
+
917
+
918
+
919
+ /*!
920
+ * @functiongroup Premultiply Data
921
+ * @discussion Multiply a non-premultiplied (normal) image with its
922
+ * alpha channel to produce a premultiplied image.
923
+ */
924
+
925
+ /*!
926
+ * @function vImagePremultiplyData_Planar8
927
+ * @abstract Multiply a Planar8 color channel by its corresponding alpha
928
+ * @discussion
929
+ * This function multiplies color channels by the alpha channel.
930
+ * <pre>@textblock
931
+ * For each color channel:
932
+ *
933
+ * uint8_t destColor = (src * alpha + 127) / 255;
934
+ *
935
+ * This function can work in place provided the following are true:
936
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
937
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
938
+ * @/textblock </pre>
939
+ *
940
+ * @param src The color data to multiply with alpha
941
+ * @param alpha The alpha data to multiply against src
942
+ * @param dest A preallocated vImage_Buffer where the results are written
943
+ * @param flags The following flags are allowed:
944
+ * <pre>@textblock
945
+ * kvImageNoFlags Default operation
946
+ *
947
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
948
+ * the work in your own tiling engine.
949
+ * @/textblock </pre>
950
+ * @result The following result codes may occur:
951
+ * <pre>@textblock
952
+ * kvImageNoError Success.
953
+ *
954
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
955
+ * dimensions in src and alpha
956
+ * @/textblock</pre>
957
+ */
958
+ VIMAGE_PF vImage_Error vImagePremultiplyData_Planar8( const vImage_Buffer *src, const vImage_Buffer *alpha, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
959
+
960
+ /*!
961
+ * @function vImagePremultiplyData_PlanarF
962
+ * @abstract Multiply a PlanarF color channel by its corresponding alpha
963
+ * @discussion
964
+ * This function multiplies color channels by the alpha channel.
965
+ * <pre>@textblock
966
+ * For each color channel:
967
+ *
968
+ * float destColor = src * alpha;
969
+ *
970
+ * This function can work in place provided the following are true:
971
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
972
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
973
+ * @/textblock </pre>
974
+ *
975
+ * @param src The color data to multiply with alpha
976
+ * @param alpha The alpha data to multiply against src
977
+ * @param dest A preallocated vImage_Buffer where the results are written
978
+ * @param flags The following flags are allowed:
979
+ * <pre>@textblock
980
+ * kvImageNoFlags Default operation
981
+ *
982
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
983
+ * the work in your own tiling engine.
984
+ * @/textblock </pre>
985
+ * @result The following result codes may occur:
986
+ * <pre>@textblock
987
+ * kvImageNoError Success.
988
+ *
989
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
990
+ * dimensions in src and alpha
991
+ * @/textblock</pre>
992
+ */
993
+ VIMAGE_PF vImage_Error vImagePremultiplyData_PlanarF( const vImage_Buffer *src, const vImage_Buffer *alpha, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
994
+
995
+ /*!
996
+ * @function vImagePremultiplyData_ARGB8888
997
+ * @abstract Multiply a ARGB8888 color channel by its corresponding alpha
998
+ * @discussion
999
+ * This function multiplies color channels by the alpha channel.
1000
+ * <pre>@textblock
1001
+ * For each color channel:
1002
+ *
1003
+ * uint8_t destColor = (src * alpha + 127) / 255;
1004
+ * uint8_t destAlpha = alpha;
1005
+ *
1006
+ * This function can work in place provided the following are true:
1007
+ * If src overlaps with dest, src->data must be equal to dest->data
1008
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1009
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1010
+ * @/textblock </pre>
1011
+ *
1012
+ * This function will for all 4 channel 8-bit / channel image formats with alpha first in memory.
1013
+ * It does not have to be ARGB.
1014
+ *
1015
+ * @param src The color data to multiply with alpha
1016
+ * @param dest A preallocated vImage_Buffer where the results are written
1017
+ * @param flags The following flags are allowed:
1018
+ * <pre>@textblock
1019
+ * kvImageNoFlags Default operation
1020
+ *
1021
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1022
+ * the work in your own tiling engine.
1023
+ * @/textblock </pre>
1024
+ * @result The following result codes may occur:
1025
+ * <pre>@textblock
1026
+ * kvImageNoError Success.
1027
+ *
1028
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1029
+ * dimensions in src and alpha
1030
+ * @/textblock</pre>
1031
+ */
1032
+ VIMAGE_PF vImage_Error vImagePremultiplyData_ARGB8888( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
1033
+
1034
+ /*!
1035
+ * @function vImagePremultiplyData_ARGBFFFF
1036
+ * @abstract Multiply a ARGBFFFF color channel by its corresponding alpha
1037
+ * @discussion
1038
+ * This function multiplies color channels by the alpha channel.
1039
+ * <pre>@textblock
1040
+ * For each color channel:
1041
+ *
1042
+ * float destColor = src * alpha;
1043
+ * float destAlpha = alpha;
1044
+ *
1045
+ * This function can work in place provided the following are true:
1046
+ * If src overlaps with dest, src->data must be equal to dest->data
1047
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1048
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1049
+ * @/textblock </pre>
1050
+ *
1051
+ * This function will for all 4 channel float / channel image formats with alpha first in memory.
1052
+ * It does not have to be ARGB.
1053
+ *
1054
+ * @param src The color data to multiply with alpha
1055
+ * @param dest A preallocated vImage_Buffer where the results are written
1056
+ * @param flags The following flags are allowed:
1057
+ * <pre>@textblock
1058
+ * kvImageNoFlags Default operation
1059
+ *
1060
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1061
+ * the work in your own tiling engine.
1062
+ * @/textblock </pre>
1063
+ * @result The following result codes may occur:
1064
+ * <pre>@textblock
1065
+ * kvImageNoError Success.
1066
+ *
1067
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1068
+ * dimensions in src and alpha
1069
+ * @/textblock</pre>
1070
+ */
1071
+ VIMAGE_PF vImage_Error vImagePremultiplyData_ARGBFFFF( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
1072
+
1073
+ /*!
1074
+ * @function vImagePremultiplyData_RGBA8888
1075
+ * @abstract Multiply a RGBA8888 color channel by its corresponding alpha
1076
+ * @discussion
1077
+ * This function multiplies color channels by the alpha channel.
1078
+ * <pre>@textblock
1079
+ * For each color channel:
1080
+ *
1081
+ * uint8_t destColor = (src * alpha + 127) / 255;
1082
+ * uint8_t destAlpha = alpha;
1083
+ *
1084
+ * This function can work in place provided the following are true:
1085
+ * If src overlaps with dest, src->data must be equal to dest->data
1086
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1087
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1088
+ * @/textblock </pre>
1089
+ *
1090
+ * This function will for all 4 channel 8-bit / channel image formats with alpha last in memory.
1091
+ * It does not have to be RGBA. Also available as vImagePremultiplyData_BGRA8888().
1092
+ *
1093
+ * @param src The color data to multiply with alpha
1094
+ * @param dest A preallocated vImage_Buffer where the results are written
1095
+ * @param flags The following flags are allowed:
1096
+ * <pre>@textblock
1097
+ * kvImageNoFlags Default operation
1098
+ *
1099
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1100
+ * the work in your own tiling engine.
1101
+ * @/textblock </pre>
1102
+ * @result The following result codes may occur:
1103
+ * <pre>@textblock
1104
+ * kvImageNoError Success.
1105
+ *
1106
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1107
+ * dimensions in src and alpha
1108
+ * @/textblock</pre>
1109
+ */
1110
+ VIMAGE_PF vImage_Error vImagePremultiplyData_RGBA8888( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1111
+ #define vImagePremultiplyData_BGRA8888( _src, _dest, _flags ) vImagePremultiplyData_RGBA8888((_src), (_dest), (_flags))
1112
+
1113
+ /*!
1114
+ * @function vImagePremultiplyData_RGBAFFFF
1115
+ * @abstract Multiply a RGBAFFFF color channel by its corresponding alpha
1116
+ * @discussion
1117
+ * This function multiplies color channels by the alpha channel.
1118
+ * <pre>@textblock
1119
+ * For each color channel:
1120
+ *
1121
+ * float destColor = src * alpha;
1122
+ * float destAlpha = alpha;
1123
+ *
1124
+ * This function can work in place provided the following are true:
1125
+ * If src overlaps with dest, src->data must be equal to dest->data
1126
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1127
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1128
+ * @/textblock </pre>
1129
+ *
1130
+ * This function will for all 4 channel float / channel image formats with alpha first in memory.
1131
+ * It does not have to be RGBA. Also available as vImagePremultiplyData_BGRAFFFF().
1132
+ *
1133
+ * @param src The color data to multiply with alpha
1134
+ * @param dest A preallocated vImage_Buffer where the results are written
1135
+ * @param flags The following flags are allowed:
1136
+ * <pre>@textblock
1137
+ * kvImageNoFlags Default operation
1138
+ *
1139
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1140
+ * the work in your own tiling engine.
1141
+ * @/textblock </pre>
1142
+ * @result The following result codes may occur:
1143
+ * <pre>@textblock
1144
+ * kvImageNoError Success.
1145
+ *
1146
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1147
+ * dimensions in src and alpha
1148
+ * @/textblock</pre>
1149
+ */
1150
+ VIMAGE_PF vImage_Error vImagePremultiplyData_RGBAFFFF( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1151
+ #define vImagePremultiplyData_BGRAFFFF( _src, _dest, _flags ) vImagePremultiplyData_RGBAFFFF((_src), (_dest), (_flags))
1152
+
1153
+ /*!
1154
+ * @function vImagePremultiplyData_RGBA16F
1155
+ * @abstract Multiply a RGBA16F color channel by its corresponding alpha
1156
+ * @discussion
1157
+ * This function multiplies color channels by the alpha channel.
1158
+ * <pre>@textblock
1159
+ * For each color channel:
1160
+ *
1161
+ * float destColor = src * alpha;
1162
+ * float destAlpha = alpha;
1163
+ *
1164
+ * This function can work in place provided the following are true:
1165
+ * If src overlaps with dest, src->data must be equal to dest->data
1166
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1167
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1168
+ * @/textblock </pre>
1169
+ *
1170
+ * This function will for all 4 channel 16F / channel image formats with alpha first in memory.
1171
+ * It does not have to be RGBA. Also available as vImagePremultiplyData_BGRA16F().
1172
+ *
1173
+ * @param src The color data to multiply with alpha
1174
+ * @param dest A preallocated vImage_Buffer where the results are written
1175
+ * @param flags The following flags are allowed:
1176
+ * <pre>@textblock
1177
+ * kvImageNoFlags Default operation
1178
+ *
1179
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1180
+ * the work in your own tiling engine.
1181
+ * @/textblock </pre>
1182
+ * @result The following result codes may occur:
1183
+ * <pre>@textblock
1184
+ * kvImageNoError Success.
1185
+ *
1186
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1187
+ * dimensions in src and alpha
1188
+ * @/textblock</pre>
1189
+ */
1190
+ VIMAGE_PF vImage_Error vImagePremultiplyData_RGBA16F( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(13.0), ios(16.0), watchos(9.0), tvos(16.0));
1191
+ #define vImagePremultiplyData_BGRA16F( _src, _dest, _flags ) vImagePremultiplyData_RGBA16F((_src), (_dest), (_flags))
1192
+
1193
+ /*!
1194
+ * @function vImagePremultiplyData_ARGB16U
1195
+ * @abstract Multiply a unsigned 16-bit ARGB color channel by its corresponding alpha
1196
+ * @discussion
1197
+ * This function multiplies color channels by the alpha channel.
1198
+ * <pre>@textblock
1199
+ * For each color channel:
1200
+ *
1201
+ * uint16_t destColor = (src * alpha + 32767) / 65535;
1202
+ * uint16_t destAlpha = alpha;
1203
+ *
1204
+ * This function can work in place provided the following are true:
1205
+ * If src overlaps with dest, src->data must be equal to dest->data
1206
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1207
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1208
+ * @/textblock </pre>
1209
+ *
1210
+ * This function will for all 4 channel uint16_t / channel image formats with alpha first in memory.
1211
+ * It does not have to be ARGB.
1212
+ *
1213
+ * @param src The color data to multiply with alpha
1214
+ * @param dest A preallocated vImage_Buffer where the results are written
1215
+ * @param flags The following flags are allowed:
1216
+ * <pre>@textblock
1217
+ * kvImageNoFlags Default operation
1218
+ *
1219
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1220
+ * the work in your own tiling engine.
1221
+ * @/textblock </pre>
1222
+ * @result The following result codes may occur:
1223
+ * <pre>@textblock
1224
+ * kvImageNoError Success.
1225
+ *
1226
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1227
+ * dimensions in src and alpha
1228
+ * @/textblock</pre>
1229
+ */
1230
+ VIMAGE_PF vImage_Error vImagePremultiplyData_ARGB16U( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.8), ios(6.0), watchos(1.0), tvos(6.0));
1231
+
1232
+ /*!
1233
+ * @function vImagePremultiplyData_RGBA16U
1234
+ * @abstract Multiply a unsigned 16-bit RGBA color channel by its corresponding alpha
1235
+ * @discussion
1236
+ * This function multiplies color channels by the alpha channel.
1237
+ * <pre>@textblock
1238
+ * For each color channel:
1239
+ *
1240
+ * uint16_t destColor = (src * alpha + 32767) / 65535;
1241
+ * uint16_t destAlpha = alpha;
1242
+ *
1243
+ * This function can work in place provided the following are true:
1244
+ * If src overlaps with dest, src->data must be equal to dest->data
1245
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1246
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1247
+ * @/textblock </pre>
1248
+ *
1249
+ * This function will for all 4 channel uint16_t / channel image formats with alpha last in memory.
1250
+ * It does not have to be RGBA. Also available as vImagePremultiplyData_BGRA16U().
1251
+ *
1252
+ * @param src The color data to multiply with alpha
1253
+ * @param dest A preallocated vImage_Buffer where the results are written
1254
+ * @param flags The following flags are allowed:
1255
+ * <pre>@textblock
1256
+ * kvImageNoFlags Default operation
1257
+ *
1258
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1259
+ * the work in your own tiling engine.
1260
+ * @/textblock </pre>
1261
+ * @result The following result codes may occur:
1262
+ * <pre>@textblock
1263
+ * kvImageNoError Success.
1264
+ *
1265
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1266
+ * dimensions in src and alpha
1267
+ * @/textblock</pre>
1268
+ */
1269
+ VIMAGE_PF vImage_Error vImagePremultiplyData_RGBA16U( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.8), ios(6.0), watchos(1.0), tvos(6.0));
1270
+ #define vImagePremultiplyData_BGRA16U( _src, _dest, _flags ) vImagePremultiplyData_RGBA16U((_src), (_dest), (_flags))
1271
+
1272
+
1273
+ /*!
1274
+ * @function vImagePremultiplyData_ARGB16Q12
1275
+ * @abstract Multiply a signed 16Q12 fixed-point ARGB color channel by its corresponding alpha
1276
+ * @discussion
1277
+ * This function multiplies color channels by the alpha channel.
1278
+ * For each color in each pixel:
1279
+ * <pre>@textblock
1280
+ * int16_t destColor = CLAMP((src * alpha + 2048) / 4096, INT16_MIN, INT16_MAX);
1281
+ * int16_t destAlpha = alpha;
1282
+ * @/textblock </pre>
1283
+ * This function can work in place provided the following are true:
1284
+ * If src overlaps with dest, src->data must be equal to dest->data
1285
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1286
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1287
+ *
1288
+ * This function will for other 4 channel 16Q12 / channel image formats with alpha first in memory.
1289
+ * It does not have to be ARGB.
1290
+ *
1291
+ * @param src The color data to multiply with alpha
1292
+ * @param dest A preallocated vImage_Buffer where the results are written
1293
+ * @param flags The following flags are allowed:
1294
+ * <pre>@textblock
1295
+ * kvImageNoFlags Default operation
1296
+ *
1297
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1298
+ * the work in your own tiling engine.
1299
+ * @/textblock </pre>
1300
+ * @result The following result codes may occur:
1301
+ * <pre>@textblock
1302
+ * kvImageNoError Success.
1303
+ *
1304
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1305
+ * dimensions in src and alpha
1306
+ * @/textblock</pre>
1307
+ */
1308
+ VIMAGE_PF vImage_Error vImagePremultiplyData_ARGB16Q12( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
1309
+
1310
+ /*!
1311
+ * @function vImagePremultiplyData_RGBA16Q12
1312
+ * @abstract Multiply a signed 16Q12 RGBA color channel by its corresponding alpha
1313
+ * @discussion
1314
+ * This function multiplies color channels by the alpha channel.
1315
+ * For each color in each pixel:
1316
+ * <pre>@textblock
1317
+ * int16_t destColor = CLAMP((src * alpha + 2048) / 4096, INT16_MIN, INT16_MAX);
1318
+ * int16_t destAlpha = alpha;
1319
+ * @/textblock </pre>
1320
+ * This function can work in place provided the following are true:
1321
+ * If src overlaps with dest, src->data must be equal to dest->data
1322
+ * If src also has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1323
+ * (It is not necessary to pass kvImageDoNotTile if src and dest do not overlap.)
1324
+ *
1325
+ * This function will for all 4 channel 16Q12 / channel image formats with alpha last in memory.
1326
+ * It does not have to be RGBA.
1327
+ *
1328
+ * @param src The color data to multiply with alpha
1329
+ * @param dest A preallocated vImage_Buffer where the results are written
1330
+ * @param flags The following flags are allowed:
1331
+ * <pre>@textblock
1332
+ * kvImageNoFlags Default operation
1333
+ *
1334
+ * kvImageDoNotTile Turn off internal multithreading. This might be useful if you are already multithreading
1335
+ * the work in your own tiling engine.
1336
+ * @/textblock </pre>
1337
+ * @result The following result codes may occur:
1338
+ * <pre>@textblock
1339
+ * kvImageNoError Success.
1340
+ *
1341
+ * kvImageRoiLargerThanInputBuffer dest->width and dest->height must be less than or equal to corresponding
1342
+ * dimensions in src and alpha
1343
+ * @/textblock</pre>
1344
+ */
1345
+ VIMAGE_PF vImage_Error vImagePremultiplyData_RGBA16Q12( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
1346
+
1347
+ /*!
1348
+ * @functiongroup Unpremultiply Data
1349
+ * @discussion Divide a premultiplied image by its alpha channel to produce a non-premultiplied image.
1350
+ */
1351
+
1352
+ /*!
1353
+ * @function vImageUnpremultiplyData_Planar8
1354
+ * @abstract Divide alpha from a premultiplied Planar8 images
1355
+ *
1356
+ * @discussion This function divides color channels by the alpha channel.
1357
+ * For each color channel:
1358
+ * <pre>@textblock
1359
+ * uint8_t destColor = ( MIN(src_color, alpha) * 255 + alpha/2) / alpha;
1360
+ * @/textblock </pre>
1361
+ * ...which is the nearest unpremultiplied result, with clamping to ensure no modulo overflow in cases where srcColor > srcAlpha.
1362
+ * In the division by zero case, the returned color value is 0.
1363
+ *
1364
+ * This function can work in place provided the following are true:
1365
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data.
1366
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1367
+ *
1368
+ * @param src The planar8 input color channel
1369
+ * @param alpha The planar8 input alpha channel
1370
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1371
+ * @param flags The following flags are allowed:
1372
+ * <pre>@textblock
1373
+ * kvImageNoFlags Default operation
1374
+ *
1375
+ * kvImageDoNotTile Disable internal multithreading.
1376
+ * @/textblock </pre>
1377
+ *
1378
+ * @result The following error codes may be returned:
1379
+ * <pre>@textblock
1380
+ * kvImageNoError Success
1381
+ *
1382
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1383
+ * @/textblock </pre>
1384
+ */
1385
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_Planar8( const vImage_Buffer *src, const vImage_Buffer *alpha, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
1386
+
1387
+
1388
+ /*!
1389
+ * @function vImageUnpremultiplyData_PlanarF
1390
+ * @abstract Divide alpha from a premultiplied PlanarF images
1391
+ *
1392
+ * @discussion This function divides color channels by the alpha channel.
1393
+ * For each color channel:
1394
+ * <pre>@textblock
1395
+ * float destColor = destColor / alpha; // according to current rounding mode
1396
+ * @/textblock </pre>
1397
+ * This function can work in place provided the following are true:
1398
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data.
1399
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1400
+ *
1401
+ * @param src The planarF input color channel
1402
+ * @param alpha The planarF input alpha channel
1403
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1404
+ * @param flags The following flags are allowed:
1405
+ * <pre>@textblock
1406
+ * kvImageNoFlags Default operation
1407
+ *
1408
+ * kvImageDoNotTile Disable internal multithreading.
1409
+ * @/textblock </pre>
1410
+ *
1411
+ * @result The following error codes may be returned:
1412
+ * <pre>@textblock
1413
+ * kvImageNoError Success
1414
+ *
1415
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1416
+ * @/textblock </pre>
1417
+ */
1418
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_PlanarF( const vImage_Buffer *src, const vImage_Buffer *alpha, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
1419
+
1420
+ /*!
1421
+ * @function vImageUnpremultiplyData_ARGB8888
1422
+ * @abstract Divide the alpha channel from the color channels in a ARGB8888 image
1423
+ * @discussion
1424
+ * This function divides color channels by the alpha channel.
1425
+ * For each color channel:
1426
+ * <pre>@textblock
1427
+ * uint8_t destColor = ( MIN(src_color, alpha) * 255 + alpha/2) / alpha;
1428
+ * uint8_t destAlpha = alpha;
1429
+ * @/textblock </pre>
1430
+ *
1431
+ * ...which is the nearest unpremultiplied result, with clamping to ensure no modulo overflow in cases where srcColor > srcAlpha.
1432
+ * In the division by zero case, the returned color value is 0.
1433
+ *
1434
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1435
+ * This function will work with other channel orders that have alpha first.
1436
+ *
1437
+ * This function can work in place provided the following are true:
1438
+ * src->data must be equal to dest->data
1439
+ * src->rowBytes must be equal to dest->rowBytes
1440
+ *
1441
+ * @param src The input inmage
1442
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1443
+ * @param flags The following flags are allowed:
1444
+ * <pre>@textblock
1445
+ * kvImageNoFlags Default operation
1446
+ *
1447
+ * kvImageDoNotTile Disable internal multithreading.
1448
+ * @/textblock </pre>
1449
+ *
1450
+ * @result The following error codes may be returned:
1451
+ * <pre>@textblock
1452
+ * kvImageNoError Success
1453
+ *
1454
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1455
+ * @/textblock </pre>
1456
+ */
1457
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_ARGB8888( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
1458
+
1459
+ /*!
1460
+ * @function vImageUnpremultiplyData_RGBA8888
1461
+ * @abstract Divide the alpha channel from the color channels in a RGBA8888 image
1462
+ * @discussion
1463
+ * This function divides color channels by the alpha channel.
1464
+ * For each color channel:
1465
+ * <pre>@textblock
1466
+ * uint8_t destColor = ( MIN(src_color, alpha) * 255 + alpha/2) / alpha;
1467
+ * uint8_t destAlpha = alpha;
1468
+ * @/textblock </pre>
1469
+ *
1470
+ * ...which is the nearest unpremultiplied result, with clamping to ensure no modulo overflow in cases where srcColor > srcAlpha.
1471
+ * In the division by zero case, the returned color value is 0.
1472
+ *
1473
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1474
+ * This function will work with other channel orders that have alpha last. The function is also available as vImageUnpremultiplyData_BGRA8888.
1475
+ *
1476
+ * This function can work in place provided the following are true:
1477
+ * src->data must be equal to dest->data
1478
+ * src->rowBytes must be equal to dest->rowBytes
1479
+ *
1480
+ * @param src The input inmage
1481
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1482
+ * @param flags The following flags are allowed:
1483
+ * <pre>@textblock
1484
+ * kvImageNoFlags Default operation
1485
+ *
1486
+ * kvImageDoNotTile Disable internal multithreading.
1487
+ * @/textblock </pre>
1488
+ *
1489
+ * @result The following error codes may be returned:
1490
+ * <pre>@textblock
1491
+ * kvImageNoError Success
1492
+ *
1493
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1494
+ * @/textblock </pre>
1495
+ */
1496
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_RGBA8888( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1497
+ #define vImageUnpremultiplyData_BGRA8888( _src, _dest, _flags ) vImageUnpremultiplyData_RGBA8888((_src), (_dest), (_flags))
1498
+
1499
+ /*!
1500
+ * @function vImageUnpremultiplyData_ARGBFFFF
1501
+ * @abstract Divide the alpha channel from the color channels in a ARGBFFFF image
1502
+ * @discussion
1503
+ * This function divides color channels by the alpha channel.
1504
+ * For each color channel:
1505
+ * <pre>@textblock
1506
+ * float destColor = destColor / alpha;
1507
+ * float destAlpha = alpha;
1508
+ * @/textblock </pre>
1509
+ *
1510
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1511
+ * This function will work with other channel orders that have alpha first.
1512
+ *
1513
+ * This function can work in place provided the following are true:
1514
+ * src->data must be equal to dest->data
1515
+ * src->rowBytes must be equal to dest->rowBytes
1516
+ *
1517
+ * @param src The input inmage
1518
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1519
+ * @param flags The following flags are allowed:
1520
+ * <pre>@textblock
1521
+ * kvImageNoFlags Default operation
1522
+ *
1523
+ * kvImageDoNotTile Disable internal multithreading.
1524
+ * @/textblock </pre>
1525
+ *
1526
+ * @result The following error codes may be returned:
1527
+ * <pre>@textblock
1528
+ * kvImageNoError Success
1529
+ *
1530
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1531
+ * @/textblock </pre>
1532
+ */
1533
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_ARGBFFFF( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.3), ios(5.0), watchos(1.0), tvos(5.0));
1534
+
1535
+
1536
+ /*!
1537
+ * @function vImageUnpremultiplyData_RGBAFFFF
1538
+ * @abstract Divide the alpha channel from the color channels in a RGBAFFFF image
1539
+ * @discussion
1540
+ * This function divides color channels by the alpha channel.
1541
+ * For each color channel:
1542
+ * <pre>@textblock
1543
+ * float destColor = destColor / alpha;
1544
+ * float destAlpha = alpha;
1545
+ * @/textblock </pre>
1546
+ *
1547
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1548
+ * This function will work with other channel orders that have alpha last. It is also available as vImageUnpremultiplyData_BGRAFFFF().
1549
+ *
1550
+ * This function can work in place provided the following are true:
1551
+ * src->data must be equal to dest->data
1552
+ * src->rowBytes must be equal to dest->rowBytes
1553
+ *
1554
+ * @param src The input inmage
1555
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1556
+ * @param flags The following flags are allowed:
1557
+ * <pre>@textblock
1558
+ * kvImageNoFlags Default operation
1559
+ *
1560
+ * kvImageDoNotTile Disable internal multithreading.
1561
+ * @/textblock </pre>
1562
+ *
1563
+ * @result The following error codes may be returned:
1564
+ * <pre>@textblock
1565
+ * kvImageNoError Success
1566
+ *
1567
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1568
+ * @/textblock </pre>
1569
+ */
1570
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_RGBAFFFF( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1571
+ #define vImageUnpremultiplyData_BGRAFFFF( _src, _dest, _flags ) vImageUnpremultiplyData_RGBAFFFF((_src), (_dest), (_flags))
1572
+
1573
+
1574
+ /*!
1575
+ * @function vImageUnpremultiplyData_RGBA16F
1576
+ * @abstract Divide the alpha channel from the color channels in a RGBA16F image
1577
+ * @discussion
1578
+ * This function divides color channels by the alpha channel.
1579
+ * For each color channel:
1580
+ * <pre>@textblock
1581
+ * float destColor = destColor / alpha;
1582
+ * float destAlpha = alpha;
1583
+ * @/textblock </pre>
1584
+ *
1585
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1586
+ * This function will work with other channel orders that have alpha last. It is also available as vImageUnpremultiplyData_BGRA16F().
1587
+ *
1588
+ * This function can work in place provided the following are true:
1589
+ * src->data must be equal to dest->data
1590
+ * src->rowBytes must be equal to dest->rowBytes
1591
+ *
1592
+ * @param src The input image
1593
+ * @param dest A preallocated 16F destination buffer into which the result will be written.
1594
+ * @param flags The following flags are allowed:
1595
+ * <pre>@textblock
1596
+ * kvImageNoFlags Default operation
1597
+ *
1598
+ * kvImageDoNotTile Disable internal multithreading.
1599
+ * @/textblock </pre>
1600
+ *
1601
+ * @result The following error codes may be returned:
1602
+ * <pre>@textblock
1603
+ * kvImageNoError Success
1604
+ *
1605
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1606
+ * @/textblock </pre>
1607
+ */
1608
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_RGBA16F( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(13.0), ios(16.0), watchos(9.0), tvos(16.0));
1609
+ #define vImageUnpremultiplyData_BGRA16F( _src, _dest, _flags ) vImageUnpremultiplyData_RGBA16F((_src), (_dest), (_flags))
1610
+
1611
+ /*!
1612
+ * @function vImageUnpremultiplyData_ARGB16U
1613
+ * @abstract Divide the alpha channel from the color channels in a ARGB16U image
1614
+ * @discussion
1615
+ * This function divides color channels by the alpha channel.
1616
+ * For each color channel:
1617
+ * <pre>@textblock
1618
+ * uint16_t destColor = ( MIN(src_color, alpha) * 65535 + alpha/2) / alpha;
1619
+ * uint16_t destAlpha = alpha;
1620
+ * @/textblock </pre>
1621
+ *
1622
+ * ...which is the nearest unpremultiplied result, with clamping to ensure no modulo overflow in cases where srcColor > srcAlpha.
1623
+ * In the division by zero case, the returned color value is 0.
1624
+ *
1625
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1626
+ * This function will work with other channel orders that have alpha first.
1627
+ *
1628
+ * This function can work in place provided the following are true:
1629
+ * src->data must be equal to dest->data
1630
+ * src->rowBytes must be equal to dest->rowBytes
1631
+ *
1632
+ * @param src The input inmage
1633
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1634
+ * @param flags The following flags are allowed:
1635
+ * <pre>@textblock
1636
+ * kvImageNoFlags Default operation
1637
+ *
1638
+ * kvImageDoNotTile Disable internal multithreading.
1639
+ * @/textblock </pre>
1640
+ *
1641
+ * @result The following error codes may be returned:
1642
+ * <pre>@textblock
1643
+ * kvImageNoError Success
1644
+ *
1645
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1646
+ * @/textblock </pre>
1647
+ */
1648
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_ARGB16U( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.8), ios(6.0), watchos(1.0), tvos(6.0));
1649
+
1650
+
1651
+ /*!
1652
+ * @function vImageUnpremultiplyData_RGBA16U
1653
+ * @abstract Divide the alpha channel from the color channels in a RGBA16U image
1654
+ * @discussion
1655
+ * This function divides color channels by the alpha channel.
1656
+ * For each color channel:
1657
+ * <pre>@textblock
1658
+ * uint16_t destColor = ( MIN(src_color, alpha) * 65535 + alpha/2) / alpha;
1659
+ * uint16_t destAlpha = alpha;
1660
+ * @/textblock </pre>
1661
+ *
1662
+ * ...which is the nearest unpremultiplied result, with clamping to ensure no modulo overflow in cases where srcColor > srcAlpha.
1663
+ * In the division by zero case, the returned color value is 0.
1664
+ *
1665
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1666
+ * This function will work with other channel orders that have alpha last. The function is also available as vImageUnpremultiplyData_BGRA16U.
1667
+ *
1668
+ * This function can work in place provided the following are true:
1669
+ * src->data must be equal to dest->data
1670
+ * src->rowBytes must be equal to dest->rowBytes
1671
+ *
1672
+ * @param src The input inmage
1673
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1674
+ * @param flags The following flags are allowed:
1675
+ * <pre>@textblock
1676
+ * kvImageNoFlags Default operation
1677
+ *
1678
+ * kvImageDoNotTile Disable internal multithreading.
1679
+ * @/textblock </pre>
1680
+ *
1681
+ * @result The following error codes may be returned:
1682
+ * <pre>@textblock
1683
+ * kvImageNoError Success
1684
+ *
1685
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1686
+ * @/textblock </pre>
1687
+ */
1688
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_RGBA16U( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.8), ios(6.0), watchos(1.0), tvos(6.0));
1689
+ #define vImageUnpremultiplyData_BGRA16U( _src, _dest, _flags ) vImageUnpremultiplyData_RGBA16U((_src), (_dest), (_flags))
1690
+
1691
+ /*!
1692
+ * @function vImageUnpremultiplyData_ARGB16Q12
1693
+ * @abstract Divide the alpha channel from the color channels in a ARGB16Q12 image
1694
+ * @discussion
1695
+ * This function divides color channels by the alpha channel.
1696
+ * For each color channel:
1697
+ * <pre>@textblock
1698
+ * int16_t destColor = ( MIN(src_color, alpha) * 4096 + alpha/2) / alpha;
1699
+ * int16_t destAlpha = alpha;
1700
+ * @/textblock </pre>
1701
+ *
1702
+ * ...which is the nearest unpremultiplied result, with clamping to ensure no modulo overflow in cases where srcColor > srcAlpha.
1703
+ * In the division by zero case, the returned color value is 0.
1704
+ *
1705
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1706
+ * This function will work with other channel orders that have alpha first.
1707
+ *
1708
+ * This function can work in place provided the following are true:
1709
+ * src->data must be equal to dest->data
1710
+ * src->rowBytes must be equal to dest->rowBytes
1711
+ *
1712
+ * @param src The input inmage
1713
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1714
+ * @param flags The following flags are allowed:
1715
+ * <pre>@textblock
1716
+ * kvImageNoFlags Default operation
1717
+ *
1718
+ * kvImageDoNotTile Disable internal multithreading.
1719
+ * @/textblock </pre>
1720
+ *
1721
+ * @result The following error codes may be returned:
1722
+ * <pre>@textblock
1723
+ * kvImageNoError Success
1724
+ *
1725
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1726
+ * @/textblock </pre>
1727
+ */
1728
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_ARGB16Q12( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
1729
+
1730
+
1731
+ /*!
1732
+ * @function vImageUnpremultiplyData_RGBA16Q12
1733
+ * @abstract Divide the alpha channel from the color channels in a RGBA16Q12 image
1734
+ * @discussion
1735
+ * This function divides color channels by the alpha channel.
1736
+ * For each color channel:
1737
+ * <pre>@textblock
1738
+ * int16_t destColor = ( MIN(src_color, alpha) * 4096 + alpha/2) / alpha;
1739
+ * int16_t destAlpha = alpha;
1740
+ * @/textblock </pre>
1741
+ *
1742
+ * ...which is the nearest unpremultiplied result, with clamping to ensure no modulo overflow in cases where srcColor > srcAlpha.
1743
+ * In the division by zero case, the returned color value is 0.
1744
+ *
1745
+ * The positioning of only the alpha channel is important for interleaved formats for these functions.
1746
+ * This function will work with other channel orders that have alpha last.
1747
+ *
1748
+ * This function can work in place provided the following are true:
1749
+ * src->data must be equal to dest->data
1750
+ * src->rowBytes must be equal to dest->rowBytes
1751
+ *
1752
+ * @param src The input inmage
1753
+ * @param dest A preallocated planar8 destination buffer into which the result will be written.'
1754
+ * @param flags The following flags are allowed:
1755
+ * <pre>@textblock
1756
+ * kvImageNoFlags Default operation
1757
+ *
1758
+ * kvImageDoNotTile Disable internal multithreading.
1759
+ * @/textblock </pre>
1760
+ *
1761
+ * @result The following error codes may be returned:
1762
+ * <pre>@textblock
1763
+ * kvImageNoError Success
1764
+ *
1765
+ * kvImageRoiLargerThanInputBuffer dest->height or width is larger than the corresponding src or alpha dimension
1766
+ * @/textblock </pre>
1767
+ */
1768
+ VIMAGE_PF vImage_Error vImageUnpremultiplyData_RGBA16Q12( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
1769
+
1770
+ /*!
1771
+ * @functiongroup Alpha Blend (Premultiplied with additional constant alpha)
1772
+ * @discussion A premultiplied alpha blend with an extra constant alpha applied to the top image to allow
1773
+ * it to be faded in our out.
1774
+ */
1775
+
1776
+ /*!
1777
+ * @function vImagePremultipliedConstAlphaBlend_Planar8
1778
+ * @abstract Blend two Planar8 premultiplied images with an extra image-wide alpha for the top image
1779
+ * @discussion This is a premultiplied alpha compositing function using a constant for alpha over the whole image.
1780
+ * Color data from both images is presumed to be already premultiplied by its own per-pixel alpha.
1781
+ * For calculations involving 8-bit integer data, the calculation is done with an additional rounding step
1782
+ * followed by division by 255:
1783
+ * <pre>@textblock
1784
+ * uint8_t destColor = (srcTopColor * constAlpha * 255 + (255*255 - srcTopAlpha * constAlpha) * srcBottomColor + 127*255) / (255*255);
1785
+ * uint8_t destAlpha = (srcTopAlpha * constAlpha * 255 + (255*255 - srcTopAlpha * constAlpha) * srcBottomAlpha + 127*255 ) / (255*255);
1786
+ * @/textblock</pre>
1787
+ * This function can work in place provided the following are true:
1788
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
1789
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1790
+ * @param srcTop The top image
1791
+ * @param constAlpha An extra alpha to apply to the entire top image
1792
+ * @param srcTopAlpha The alpha channel for the top image
1793
+ * @param srcBottom The bottom image
1794
+ * @param dest A preallocate vImage_Buffer where the result will be written
1795
+ * @param flags The following flags are allowed:
1796
+ * <pre>@textblock
1797
+ * kvImageNoFlags Default operation
1798
+ *
1799
+ * kvImageDoNotTile Turn off internal multithreading
1800
+ * @/textblock</pre>
1801
+ * @return The following error codes may be returned:
1802
+ * <pre>@textblock
1803
+ * kvImageNoError Success
1804
+ *
1805
+ * kvImageRoiLargerThanInputBuffer The destination buffer height or width is larger than the corresponding dimension in
1806
+ * srcTop, srcTopAlpha or srcBottom
1807
+ * @/textblock</pre>
1808
+ */
1809
+ VIMAGE_PF vImage_Error vImagePremultipliedConstAlphaBlend_Planar8( const vImage_Buffer *srcTop, Pixel_8 constAlpha, const vImage_Buffer *srcTopAlpha, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,3,4,5) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1810
+
1811
+ /*!
1812
+ * @function vImagePremultipliedConstAlphaBlend_PlanarF
1813
+ * @abstract Blend two PlanarF premultiplied images with an extra image-wide alpha for the top image
1814
+ * @discussion This is a premultiplied alpha compositing function using a constant for alpha over the whole image.
1815
+ * Color data from both images is presumed to be already premultiplied by its own per-pixel alpha.
1816
+ * <pre>@textblock
1817
+ * float destColor = srcTopColor * constAlpha + (1.0 - srcTopAlpha * constAlpha) * srcBottomColor;
1818
+ * float alpha = srcTopAlpha * constAlpha + (1.0 - srcTopAlpha * constAlpha) * srcBottomAlpha
1819
+ * @/textblock </pre>
1820
+ * This function can work in place provided the following are true:
1821
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
1822
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1823
+ * @param srcTop The top image
1824
+ * @param constAlpha An extra alpha to apply to the entire top image
1825
+ * @param srcTopAlpha The alpha channel for the top image
1826
+ * @param srcBottom The bottom image
1827
+ * @param dest A preallocate vImage_Buffer where the result will be written
1828
+ * @param flags The following flags are allowed:
1829
+ * <pre>@textblock
1830
+ * kvImageNoFlags Default operation
1831
+ *
1832
+ * kvImageDoNotTile Turn off internal multithreading
1833
+ * @/textblock</pre>
1834
+ * @return The following error codes may be returned:
1835
+ * <pre>@textblock
1836
+ * kvImageNoError Success
1837
+ *
1838
+ * kvImageRoiLargerThanInputBuffer The destination buffer height or width is larger than the corresponding dimension in
1839
+ * srcTop, srcTopAlpha or srcBottom
1840
+ * @/textblock</pre>
1841
+ */
1842
+ VIMAGE_PF vImage_Error vImagePremultipliedConstAlphaBlend_PlanarF( const vImage_Buffer *srcTop, Pixel_F constAlpha, const vImage_Buffer *srcTopAlpha, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,3,4,5) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1843
+
1844
+ /*!
1845
+ * @function vImagePremultipliedConstAlphaBlend_ARGB8888
1846
+ * @abstract Blend two ARGB8888 premultiplied images with an extra image-wide alpha for the top image
1847
+ * @discussion This is a premultiplied alpha compositing function using a constant for alpha over the whole image.
1848
+ * Color data from both images is presumed to be already premultiplied by its own per-pixel alpha.
1849
+ * For calculations involving 8-bit integer data, the calculation is done with an additional rounding step
1850
+ * followed by division by 255:
1851
+ * <pre>@textblock
1852
+ * uint8_t destColor = (srcTopColor * constAlpha * 255 + (255*255 - srcTopAlpha * constAlpha) * srcBottomColor + 127*255) / (255*255);
1853
+ * uint8_t destAlpha = (srcTopAlpha * constAlpha * 255 + (255*255 - srcTopAlpha * constAlpha) * srcBottomAlpha + 127*255 ) / (255*255);
1854
+ * @/textblock</pre>
1855
+ * This function can work in place provided the following are true:
1856
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
1857
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1858
+ *
1859
+ * The function will work for all 4 channel 8-bit / channel image formats with alpha first in memory, not just ARGB.
1860
+ * @param srcTop The top image
1861
+ * @param constAlpha An extra alpha to apply to the entire top image
1862
+ * @param srcBottom The bottom image
1863
+ * @param dest A preallocate vImage_Buffer where the result will be written
1864
+ * @param flags The following flags are allowed:
1865
+ * <pre>@textblock
1866
+ * kvImageNoFlags Default operation
1867
+ *
1868
+ * kvImageDoNotTile Turn off internal multithreading
1869
+ * @/textblock</pre>
1870
+ * @return The following error codes may be returned:
1871
+ * <pre>@textblock
1872
+ * kvImageNoError Success
1873
+ *
1874
+ * kvImageRoiLargerThanInputBuffer The destination buffer height or width is larger than the corresponding dimension in
1875
+ * srcTop, srcTopAlpha or srcBottom
1876
+ * @/textblock</pre>
1877
+ */
1878
+ VIMAGE_PF vImage_Error vImagePremultipliedConstAlphaBlend_ARGB8888( const vImage_Buffer *srcTop, Pixel_8 constAlpha, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,3,4) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1879
+
1880
+ /*!
1881
+ * @function vImagePremultipliedConstAlphaBlend_ARGBFFFF
1882
+ * @abstract Blend two ARGBFFFF premultiplied images with an extra image-wide alpha for the top image
1883
+ * @discussion This is a premultiplied alpha compositing function using a constant for alpha over the whole image.
1884
+ * Color data from both images is presumed to be already premultiplied by its own per-pixel alpha.
1885
+ * For calculations involving 8-bit integer data, the calculation is done with an additional rounding step
1886
+ * followed by division by 255:
1887
+ * <pre>@textblock
1888
+ * float destColor = srcTopColor * constAlpha + (1.0 - srcTopAlpha * constAlpha) * srcBottomColor;
1889
+ * float alpha = srcTopAlpha * constAlpha + (1.0 - srcTopAlpha * constAlpha) * srcBottomAlpha
1890
+ * @/textblock</pre>
1891
+ * This function can work in place provided the following are true:
1892
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
1893
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1894
+ *
1895
+ * The function will work for all 4 channel float / channel image formats with alpha first in memory, not just ARGB.
1896
+ * @param srcTop The top image
1897
+ * @param constAlpha An extra alpha to apply to the entire top image
1898
+ * @param srcBottom The bottom image
1899
+ * @param dest A preallocate vImage_Buffer where the result will be written
1900
+ * @param flags The following flags are allowed:
1901
+ * <pre>@textblock
1902
+ * kvImageNoFlags Default operation
1903
+ *
1904
+ * kvImageDoNotTile Turn off internal multithreading
1905
+ * @/textblock</pre>
1906
+ * @return The following error codes may be returned:
1907
+ * <pre>@textblock
1908
+ * kvImageNoError Success
1909
+ *
1910
+ * kvImageRoiLargerThanInputBuffer The destination buffer height or width is larger than the corresponding dimension in
1911
+ * srcTop, srcTopAlpha or srcBottom
1912
+ * @/textblock</pre>
1913
+ */
1914
+ VIMAGE_PF vImage_Error vImagePremultipliedConstAlphaBlend_ARGBFFFF( const vImage_Buffer *srcTop, Pixel_F constAlpha, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,3,4) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1915
+
1916
+ /*!
1917
+ * @functiongroup Alpha Blend (Non-premultiplied to premultiplied)
1918
+ * @discussion These functions blend a non-premultiplied top image into a premultiplied bottom image
1919
+ * to produce a premultiplied result.
1920
+ */
1921
+
1922
+ /*!
1923
+ * @function vImageAlphaBlend_NonpremultipliedToPremultiplied_Planar8
1924
+ * @abstract Blend a non-premultiplied top Planar8 image into a premultiplied Planar8 bottom image and return a premultiplied Planar8 result.
1925
+ * @discussion Top buffer is non-premultiplied. Bottom buffer is premultiplied. Dest buffer is premultiplied. Works in place.
1926
+ * <pre>@textblock
1927
+ * result = (srcTop * srctopAlpha + (255 - srcTopAlpha) * bottomAlpha + 127 ) / 255;
1928
+ * @/textblock </pre>
1929
+ * This function will work in place as long as the src and dest buffer overlap exactly.
1930
+ * The src buffers must be at least as large as the dest buffer in each dimension. (src.height >= dest.height && src.width >= dest.width)
1931
+ *
1932
+ * To calculate the alpha result for the Planar cases, use
1933
+ * <pre>@textblock
1934
+ * vImagePremultipliedAlphaBlend_Planar8( srcTopAlpha, srcTopAlpha, srcBottomAlpha, dest, flags );
1935
+ * @/textblock </pre>
1936
+ * This function can work in place provided the following are true:
1937
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
1938
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1939
+ *
1940
+ * @param srcTop Planar8 non-premultiplied color channel for top image
1941
+ * @param srcTopAlpha Planar8 alpha channel for top image
1942
+ * @param srcBottom Planar8 premultiplied color channel for bottom image
1943
+ * @param dest Planar8 premultiplied result. Must be preallocated before the call is made.
1944
+ * @param flags The following flags are allowed:
1945
+ * <pre> @textblock
1946
+ * kvImageNoFlags Default operation.
1947
+ *
1948
+ * kvImageDoNotTile Disable internal multithreading.
1949
+ * @/textblock </pre>
1950
+ * @result The following error codes may occur:
1951
+ * <pre> @textblock
1952
+ * kvImageNoError Success.
1953
+ *
1954
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
1955
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
1956
+ * @/textblock </pre>
1957
+ */
1958
+ VIMAGE_PF vImage_Error vImageAlphaBlend_NonpremultipliedToPremultiplied_Planar8( const vImage_Buffer *srcTop, const vImage_Buffer *srcTopAlpha, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3,4) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1959
+
1960
+ /*!
1961
+ * @function vImageAlphaBlend_NonpremultipliedToPremultiplied_PlanarF
1962
+ * @abstract Blend a non-premultiplied top PlanarF image into a premultiplied PlanarF bottom image and return a premultiplied PlanarF result.
1963
+ * @discussion Top buffer is non-premultiplied. Bottom buffer is premultiplied. Dest buffer is premultiplied. Works in place.
1964
+ * <pre>@textblock
1965
+ * result = srcTop * srcTopAlpha + (1 - srcTopAlpha) * srcBottom
1966
+ * @/textblock </pre>
1967
+ * This function will work in place as long as the src and dest buffer overlap exactly.
1968
+ * The src buffers must be at least as large as the dest buffer in each dimension. (src.height >= dest.height && src.width >= dest.width)
1969
+ *
1970
+ * To calculate the alpha result for the Planar cases, use
1971
+ * <pre>@textblock
1972
+ * vImagePremultipliedAlphaBlend_PlanarF( srcTopAlpha, srcTopAlpha, srcBottomAlpha, dest, flags );
1973
+ * @/textblock </pre>
1974
+ * This function can work in place provided the following are true:
1975
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
1976
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
1977
+ *
1978
+ * @param srcTop Planar8 non-premultiplied color channel for top image
1979
+ * @param srcTopAlpha Planar8 alpha channel for top image
1980
+ * @param srcBottom Planar8 premultiplied color channel for bottom image
1981
+ * @param dest Planar8 premultiplied result. Must be preallocated before the call is made.
1982
+ * @param flags The following flags are allowed:
1983
+ * <pre> @textblock
1984
+ * kvImageNoFlags Default operation.
1985
+ *
1986
+ * kvImageDoNotTile Disable internal multithreading.
1987
+ * @/textblock </pre>
1988
+ * @result The following error codes may occur:
1989
+ * <pre> @textblock
1990
+ * kvImageNoError Success.
1991
+ *
1992
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
1993
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
1994
+ * @/textblock </pre>
1995
+ */
1996
+ VIMAGE_PF vImage_Error vImageAlphaBlend_NonpremultipliedToPremultiplied_PlanarF( const vImage_Buffer *srcTop, const vImage_Buffer *srcTopAlpha, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3,4) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
1997
+
1998
+ /*!
1999
+ * @function vImageAlphaBlend_NonpremultipliedToPremultiplied_ARGB8888
2000
+ * @abstract Blend a non-premultiplied top ARGB8888 image into a premultiplied ARGB8888 bottom image and return a premultiplied ARGB8888 result.
2001
+ * @discussion Top buffer is non-premultiplied. Bottom buffer is premultiplied. Dest buffer is premultiplied. Works in place.
2002
+ * <pre>@textblock
2003
+ * result = (srcTop * srctopAlpha + (255 - srcTopAlpha) * bottomAlpha + 127 ) / 255;
2004
+ * @/textblock </pre>
2005
+ * This function will work in place as long as the src and dest buffer overlap exactly.
2006
+ * The src buffers must be at least as large as the dest buffer in each dimension. (src.height >= dest.height && src.width >= dest.width)
2007
+ *
2008
+ * This function can work in place provided the following are true:
2009
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
2010
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
2011
+ *
2012
+ * This function will work with any channel order with alpha first, not just ARGB.
2013
+ *
2014
+ * @param srcTop Planar8 non-premultiplied color channel for top image
2015
+ * @param srcBottom Planar8 premultiplied color channel for bottom image
2016
+ * @param dest Planar8 premultiplied result. Must be preallocated before the call is made.
2017
+ * @param flags The following flags are allowed:
2018
+ * <pre> @textblock
2019
+ * kvImageNoFlags Default operation.
2020
+ *
2021
+ * kvImageDoNotTile Disable internal multithreading.
2022
+ * @/textblock </pre>
2023
+ * @result The following error codes may occur:
2024
+ * <pre> @textblock
2025
+ * kvImageNoError Success.
2026
+ *
2027
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
2028
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
2029
+ * @/textblock </pre>
2030
+ */
2031
+ VIMAGE_PF vImage_Error vImageAlphaBlend_NonpremultipliedToPremultiplied_ARGB8888( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
2032
+
2033
+ /*!
2034
+ * @function vImageAlphaBlend_NonpremultipliedToPremultiplied_ARGBFFFF
2035
+ * @abstract Blend a non-premultiplied top ARGBFFFF image into a premultiplied ARGBFFFF bottom image and return a premultiplied ARGBFFFF result.
2036
+ * @discussion Top buffer is non-premultiplied. Bottom buffer is premultiplied. Dest buffer is premultiplied. Works in place.
2037
+ * <pre>@textblock
2038
+ * result = srcTop * srcTopAlpha + (1 - srcTopAlpha) * srcBottom
2039
+ * @/textblock </pre>
2040
+ * This function will work in place as long as the src and dest buffer overlap exactly.
2041
+ * The src buffers must be at least as large as the dest buffer in each dimension. (src.height >= dest.height && src.width >= dest.width)
2042
+ *
2043
+ * This function can work in place provided the following are true:
2044
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
2045
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
2046
+ *
2047
+ * This function will work with any channel order with alpha first, not just ARGB.
2048
+ *
2049
+ * @param srcTop Planar8 non-premultiplied color channel for top image
2050
+ * @param srcBottom Planar8 premultiplied color channel for bottom image
2051
+ * @param dest Planar8 premultiplied result. Must be preallocated before the call is made.
2052
+ * @param flags The following flags are allowed:
2053
+ * <pre> @textblock
2054
+ * kvImageNoFlags Default operation.
2055
+ *
2056
+ * kvImageDoNotTile Disable internal multithreading.
2057
+ * @/textblock </pre>
2058
+ * @result The following error codes may occur:
2059
+ * <pre> @textblock
2060
+ * kvImageNoError Success.
2061
+ *
2062
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
2063
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
2064
+ * @/textblock </pre>
2065
+ */
2066
+ VIMAGE_PF vImage_Error vImageAlphaBlend_NonpremultipliedToPremultiplied_ARGBFFFF( const vImage_Buffer *srcTop, const vImage_Buffer *srcBottom, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
2067
+
2068
+ /*!
2069
+ * @functiongroup Clip To Alpha
2070
+ * @discusssion If a premultiplied image color channel has a value greater than alpha it is super-opaque. This may
2071
+ * cause problems later in compositing operations. Alpha > color can happen normally as a result of
2072
+ * convolutions, resampling, and morphological operations. While such operations should generally be done
2073
+ * on non-premultiplied content, sometimes premultiplied content slips through. vImage provides a clamping
2074
+ * function vImageClipToAlpha which identify color channels that are greater than alpha and clamp them to be
2075
+ * equal to alpha.
2076
+ */
2077
+
2078
+ /*!
2079
+ * @function vImageClipToAlpha_Planar8
2080
+ * @abstract Clamp a Planar8 color buffer to be less than or equal to alpha
2081
+ * @discussion
2082
+ * For each pixel, each color channel shall be set to the smaller of the color channel or alpha value for that pixel.
2083
+ * <pre>@textblock
2084
+ * color_result = MIN( color, alpha )
2085
+ * @/textblock </pre>
2086
+ * This function can work in place provided the following are true:
2087
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
2088
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
2089
+ * @param src The color image to clip
2090
+ * @param alpha The alpha channel
2091
+ * @param dest A preallocated buffer to receive the results.
2092
+ * @param flags The following flags are allowed:
2093
+ * <pre> @textblock
2094
+ * kvImageNoFlags Default operation.
2095
+ *
2096
+ * kvImageDoNotTile Disable internal multithreading.
2097
+ * @/textblock </pre>
2098
+ * @result The following error codes may occur:
2099
+ * <pre> @textblock
2100
+ * kvImageNoError Success.
2101
+ *
2102
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
2103
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
2104
+ * @/textblock </pre>
2105
+ */
2106
+ VIMAGE_PF vImage_Error vImageClipToAlpha_Planar8( const vImage_Buffer *src, const vImage_Buffer *alpha, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
2107
+
2108
+ /*!
2109
+ * @function vImageClipToAlpha_PlanarF
2110
+ * @abstract Clamp a PlanarF color buffer to be less than or equal to alpha
2111
+ * @discussion
2112
+ * For each pixel, each color channel shall be set to the smaller of the color channel or alpha value for that pixel.
2113
+ * <pre>@textblock
2114
+ * color_result = MIN( color, alpha )
2115
+ * @/textblock </pre>
2116
+ * This function can work in place provided the following are true:
2117
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
2118
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
2119
+ * @param src The color image to clip
2120
+ * @param alpha The alpha channel
2121
+ * @param dest A preallocated buffer to receive the results.
2122
+ * @param flags The following flags are allowed:
2123
+ * <pre> @textblock
2124
+ * kvImageNoFlags Default operation.
2125
+ *
2126
+ * kvImageDoNotTile Disable internal multithreading.
2127
+ * @/textblock </pre>
2128
+ * @result The following error codes may occur:
2129
+ * <pre> @textblock
2130
+ * kvImageNoError Success.
2131
+ *
2132
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
2133
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
2134
+ * @/textblock </pre>
2135
+ */
2136
+ VIMAGE_PF vImage_Error vImageClipToAlpha_PlanarF( const vImage_Buffer *src, const vImage_Buffer *alpha, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2,3) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
2137
+
2138
+ /*!
2139
+ * @function vImageClipToAlpha_ARGB8888
2140
+ * @abstract Clamp a ARGB8888 color buffer to be less than or equal to alpha
2141
+ * @discussion
2142
+ * For each pixel, each color channel shall be set to the smaller of the color channel or alpha value for that pixel.
2143
+ * <pre>@textblock
2144
+ * alpha_result = alpha
2145
+ * color_result = MIN( color, alpha )
2146
+ * @/textblock </pre>
2147
+ * This function can work in place provided the following are true:
2148
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
2149
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
2150
+ *
2151
+ * This function will work for any channel order with alpha first, not just ARGB.
2152
+ *
2153
+ * @param src The color image to clip
2154
+ * @param dest A preallocated buffer to receive the results.
2155
+ * @param flags The following flags are allowed:
2156
+ * <pre> @textblock
2157
+ * kvImageNoFlags Default operation.
2158
+ *
2159
+ * kvImageDoNotTile Disable internal multithreading.
2160
+ * @/textblock </pre>
2161
+ * @result The following error codes may occur:
2162
+ * <pre> @textblock
2163
+ * kvImageNoError Success.
2164
+ *
2165
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
2166
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
2167
+ * @/textblock </pre>
2168
+ */
2169
+ VIMAGE_PF vImage_Error vImageClipToAlpha_ARGB8888( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
2170
+
2171
+ /*!
2172
+ * @function vImageClipToAlpha_ARGBFFFF
2173
+ * @abstract Clamp a ARGBFFFF color buffer to be less than or equal to alpha
2174
+ * @discussion
2175
+ * For each pixel, each color channel shall be set to the smaller of the color channel or alpha value for that pixel.
2176
+ * <pre>@textblock
2177
+ * alpha_result = alpha
2178
+ * color_result = MIN( color, alpha )
2179
+ * @/textblock </pre>
2180
+ * This function can work in place provided the following are true:
2181
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
2182
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
2183
+ *
2184
+ * This function will work for any channel order with alpha first, not just ARGB.
2185
+ *
2186
+ * @param src The color image to clip
2187
+ * @param dest A preallocated buffer to receive the results.
2188
+ * @param flags The following flags are allowed:
2189
+ * <pre> @textblock
2190
+ * kvImageNoFlags Default operation.
2191
+ *
2192
+ * kvImageDoNotTile Disable internal multithreading.
2193
+ * @/textblock </pre>
2194
+ * @result The following error codes may occur:
2195
+ * <pre> @textblock
2196
+ * kvImageNoError Success.
2197
+ *
2198
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
2199
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
2200
+ * @/textblock </pre>
2201
+ */
2202
+ VIMAGE_PF vImage_Error vImageClipToAlpha_ARGBFFFF( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.4), ios(5.0), watchos(1.0), tvos(5.0));
2203
+
2204
+ /*!
2205
+ * @function vImageClipToAlpha_RGBA8888
2206
+ * @abstract Clamp a RGBA8888 color buffer to be less than or equal to alpha
2207
+ * @discussion
2208
+ * For each pixel, each color channel shall be set to the smaller of the color channel or alpha value for that pixel.
2209
+ * <pre>@textblock
2210
+ * alpha_result = alpha
2211
+ * color_result = MIN( color, alpha )
2212
+ * @/textblock </pre>
2213
+ * This function can work in place provided the following are true:
2214
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
2215
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
2216
+ *
2217
+ * This function will work for any channel order with alpha last, not just RGBA. Also available as vImageClipToAlpha_BGRA8888().
2218
+ *
2219
+ * @param src The color image to clip
2220
+ * @param dest A preallocated buffer to receive the results.
2221
+ * @param flags The following flags are allowed:
2222
+ * <pre> @textblock
2223
+ * kvImageNoFlags Default operation.
2224
+ *
2225
+ * kvImageDoNotTile Disable internal multithreading.
2226
+ * @/textblock </pre>
2227
+ * @result The following error codes may occur:
2228
+ * <pre> @textblock
2229
+ * kvImageNoError Success.
2230
+ *
2231
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
2232
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
2233
+ * @/textblock </pre>
2234
+ */
2235
+ VIMAGE_PF vImage_Error vImageClipToAlpha_RGBA8888( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.8), ios(6.0), watchos(1.0), tvos(6.0));
2236
+ #define vImageClipToAlpha_BGRA8888(_src, _dest, _flags) vImageClipToAlpha_RGBA8888((_src), (_dest), (_flags))
2237
+
2238
+ /*!
2239
+ * @function vImageClipToAlpha_RGBAFFFF
2240
+ * @abstract Clamp a RGBAFFFF color buffer to be less than or equal to alpha
2241
+ * @discussion
2242
+ * For each pixel, each color channel shall be set to the smaller of the color channel or alpha value for that pixel.
2243
+ * <pre>@textblock
2244
+ * alpha_result = alpha
2245
+ * color_result = MIN( color, alpha )
2246
+ * @/textblock </pre>
2247
+ * This function can work in place provided the following are true:
2248
+ * For each buffer "buf" that overlaps with dest, buf->data must be equal to dest->data
2249
+ * If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile must be also passed in the flags
2250
+ *
2251
+ * This function will work for any channel order with alpha last, not just RGBA. Also available as vImageClipToAlpha_BGRAFFFF().
2252
+ *
2253
+ * @param src The color image to clip
2254
+ * @param dest A preallocated buffer to receive the results.
2255
+ * @param flags The following flags are allowed:
2256
+ * <pre> @textblock
2257
+ * kvImageNoFlags Default operation.
2258
+ *
2259
+ * kvImageDoNotTile Disable internal multithreading.
2260
+ * @/textblock </pre>
2261
+ * @result The following error codes may occur:
2262
+ * <pre> @textblock
2263
+ * kvImageNoError Success.
2264
+ *
2265
+ * kvImageRoiLargerThanInputBuffer dest->height and dest->width must be less than or equal to corresponding
2266
+ * dimensions in srcTop, srcTopAlpha and srcBottom.
2267
+ * @/textblock </pre>
2268
+ */
2269
+ VIMAGE_PF vImage_Error vImageClipToAlpha_RGBAFFFF( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags ) VIMAGE_NON_NULL(1,2) API_AVAILABLE(macos(10.8), ios(6.0), watchos(1.0), tvos(6.0));
2270
+ #define vImageClipToAlpha_BGRAFFFF(_src, _dest, _flags) vImageClipToAlpha_RGBAFFFF((_src), (_dest), (_flags))
2271
+
2272
+ /*
2273
+ * See also the vImageFlatten APIs in Conversion.h for compositing an image against a constant color opaque background.
2274
+ */
2275
+
2276
+ #ifdef __cplusplus
2277
+ }
2278
+ #endif
2279
+
2280
+ #endif /* vImage_ALPHA_H */
2281
+
2282
+