objc2_core_image/generated/
CIContext.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10#[cfg(feature = "objc2-core-video")]
11use objc2_core_video::*;
12use objc2_foundation::*;
13#[cfg(feature = "objc2-image-io")]
14use objc2_image_io::*;
15#[cfg(feature = "objc2-io-surface")]
16use objc2_io_surface::*;
17#[cfg(feature = "objc2-metal")]
18use objc2_metal::*;
19#[cfg(feature = "objc2-open-gl")]
20#[cfg(target_os = "macos")]
21use objc2_open_gl::*;
22
23use crate::*;
24
25/// An enum string type that your code can use to select different options when creating a Core Image context.
26///
27/// These option keys can be passed to `CIContext` creation APIs such as:
28/// * ``/CIContext/contextWithOptions:``
29/// * ``/CIContext/contextWithMTLDevice:options:``
30///
31/// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/cicontextoption?language=objc)
32// NS_TYPED_ENUM
33pub type CIContextOption = NSString;
34
35extern "C" {
36    /// A Core Image context option key to specify the default destination color space for rendering.
37    ///
38    /// This option only affects how Core Image renders using the following methods:
39    /// * ``/CIContext/createCGImage:fromRect:``
40    /// * ``/CIContext/drawImage:atPoint:fromRect:``
41    /// * ``/CIContext/drawImage:inRect:fromRect:``
42    ///
43    /// With all other render methods, the destination color space is either specified as a parameter
44    /// or can be determined from the object being rendered to.
45    ///
46    /// The value of this option can be either:
47    /// * A `CGColorSpace` instance with an RGB or monochrome color model that supports output.
48    /// * An `NSNull` instance to indicate that the context should not match from the working space to the destination.
49    ///
50    /// If this option is not specified, then the default output space is sRGB.
51    ///
52    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextoutputcolorspace?language=objc)
53    pub static kCIContextOutputColorSpace: &'static CIContextOption;
54}
55
56extern "C" {
57    /// A Core Image context option key to specify the working color space for rendering.
58    ///
59    /// Contexts support automatic color management by performing all processing operations
60    /// in a working color space. This means that unless told otherwise:
61    /// * All input images are color matched from the input's color space to the working space.
62    /// * All renders are color matched from the working space to the destination's color space.
63    ///
64    /// The default working space is the extended sRGB color space with linear gamma.
65    /// On macOS before 10.10, the default is extended Generic RGB with linear gamma.
66    ///
67    /// The value of this option can be either:
68    /// * A `CGColorSpace` instance with an RGB color model that supports output.
69    /// * An `NSNull` instance to request that Core Image perform no color management.
70    ///
71    /// If this option is not specified, then the default working space is used.
72    ///
73    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextworkingcolorspace?language=objc)
74    pub static kCIContextWorkingColorSpace: &'static CIContextOption;
75}
76
77extern "C" {
78    /// A Core Image context option key to specify the pixel format to for intermediate results when rendering.
79    ///
80    /// The value for this key is an `NSNumber` instance containing a ``CIFormat`` value.
81    ///
82    /// The supported values for the working pixel format are:
83    /// ``CIFormat``        | Notes
84    /// ------------------- | --------------
85    /// ``kCIFormatRGBA8``  | Uses less memory but has less precision an range
86    /// ``kCIFormatRGBAh``  | Uses 8 bytes per pixel, supports HDR
87    /// ``kCIFormatRGBAf``  | Only on macOS
88    ///
89    /// If this option is not specified, then the default is ``kCIFormatRGBAh``.
90    ///
91    /// (The default is ``kCIFormatRGBA8`` if your if app is linked against iOS 12 SDK or earlier.)
92    ///
93    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextworkingformat?language=objc)
94    pub static kCIContextWorkingFormat: &'static CIContextOption;
95}
96
97extern "C" {
98    /// A Boolean value to control the quality of image downsampling operations performed by the
99    /// Core Image context.
100    ///
101    /// The higher quality behavior performs downsampling operations in multiple passes
102    /// in order to reduce aliasing artifacts.
103    ///
104    /// The lower quality behavior performs downsampling operations a single pass
105    /// in order to improve performance.
106    ///
107    /// If the value for this option is:
108    /// * True: The higher quality behavior will be used.
109    /// * False: The lower quality behavior will be used.
110    /// * Not specified: the default behavior is True on macOS and False on other platforms.
111    ///
112    /// > Note:
113    /// > * This option does affect how ``/CIImage/imageByApplyingTransform:`` operations are performed by the context.
114    /// > * This option does not affect how ``/CIImage/imageByApplyingTransform:highQualityDownsample:`` behaves.
115    ///
116    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontexthighqualitydownsample?language=objc)
117    pub static kCIContextHighQualityDownsample: &'static CIContextOption;
118}
119
120extern "C" {
121    /// A Boolean value to control how a Core Image context render produces alpha-premultiplied pixels.
122    ///
123    /// This option only affects how a context is rendered when using methods where the destination's
124    /// alpha mode cannot be determined such as:
125    /// *  ``/CIContext/render:toBitmap:rowBytes:bounds:format:colorSpace:``
126    /// *  ``/CIContext/render:toCVPixelBuffer:``
127    /// *  ``/CIContext/render:toIOSurface:bounds:colorSpace:``
128    /// *  ``/CIContext/render:toMTLTexture:commandBuffer:bounds:colorSpace:``
129    /// *  ``/CIContext/createCGImage:fromRect:``
130    ///
131    /// If the value for this option is:
132    /// * True: The output will produce alpha-premultiplied pixels.
133    /// * False: The output will produce un-premultiplied pixels.
134    /// * Not specified: the default behavior True.
135    ///
136    /// This option does not affect how a context is rendered to a ``CIRenderDestination`` because
137    /// that API allows you to set or override the alpha behavior using ``/CIRenderDestination/alphaMode``.
138    ///
139    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextoutputpremultiplied?language=objc)
140    pub static kCIContextOutputPremultiplied: &'static CIContextOption;
141}
142
143extern "C" {
144    /// A Boolean value to control how a Core Image context caches the contents of any intermediate image buffers it uses during rendering.
145    ///
146    /// If a context caches intermediate buffers, then subsequent renders of a similar image using the same context
147    /// may be able to render faster. If a context does not cache intermediate buffers, then it may use less memory.
148    ///
149    /// If the value for this option is:
150    /// * True: The context will cache intermediate results for future renders using the same context.
151    /// * False: The context will not cache intermediate results.
152    /// * Not specified: the default behavior True.
153    ///
154    /// > Note:
155    /// > * This option does affect how ``/CIImage/imageByInsertingIntermediate`` behaves.
156    /// > * This option does not affect how ``/CIImage/imageByInsertingIntermediate:`` behaves.
157    ///
158    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextcacheintermediates?language=objc)
159    pub static kCIContextCacheIntermediates: &'static CIContextOption;
160}
161
162extern "C" {
163    /// A Boolean value to control if a Core Image context will use a software renderer.
164    ///
165    /// > Note: This option has no effect if the platform does not support OpenCL.
166    ///
167    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextusesoftwarerenderer?language=objc)
168    pub static kCIContextUseSoftwareRenderer: &'static CIContextOption;
169}
170
171extern "C" {
172    /// A Boolean value to control the priority Core Image context renders.
173    ///
174    /// If this value is True, then rendering with the context from a background thread takes lower priority
175    /// than other GPU usage from the main thread. This allows your app to perform Core Image rendering without
176    /// disturbing the frame rate of UI animations.
177    ///
178    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextpriorityrequestlow?language=objc)
179    pub static kCIContextPriorityRequestLow: &'static CIContextOption;
180}
181
182extern "C" {
183    /// A Boolean value to control the power level of Core Image context renders.
184    ///
185    /// This option only affects certain macOS devices with more than one available GPU device.
186    ///
187    /// If this value is True, then rendering with the context will use a use allow power GPU device
188    /// if available and the high power device is not already in use.
189    ///
190    /// Otherwise, the context will use the highest power/performance GPU device.
191    ///
192    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextallowlowpower?language=objc)
193    pub static kCIContextAllowLowPower: &'static CIContextOption;
194}
195
196extern "C" {
197    /// A Boolean value to specify a client-provided name for a context.
198    ///
199    /// This name will be used in QuickLook graphs and the output of CI_PRINT_TREE.
200    ///
201    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextname?language=objc)
202    pub static kCIContextName: &'static CIContextOption;
203}
204
205extern "C" {
206    /// A Core Video Metal texture cache object to improve the performance of Core Image context
207    /// renders that use Core Video pixel buffers.
208    ///
209    /// Creating a Core Image context with this optional `CVMetalTextureCache` can improve the
210    /// performance of creating a Metal texture from a `CVPixelBuffer`. It is recommended
211    /// to specify this option if the context renders to or from pixel buffers that come
212    /// from a `CVPixelBufferPool`.
213    ///
214    /// It is the client's responsibility to flush the cache when appropriate.
215    ///
216    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextcvmetaltexturecache?language=objc)
217    pub static kCIContextCVMetalTextureCache: &'static CIContextOption;
218}
219
220extern "C" {
221    /// A number value to control the maximum memory in megabytes that the context allocates for render tasks.
222    ///
223    /// Larger values could increase memory  footprint while smaller values could reduce performance.
224    ///
225    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kcicontextmemorylimit?language=objc)
226    pub static kCIContextMemoryLimit: &'static CIContextOption;
227}
228
229extern_class!(
230    /// The Core Image context class provides an evaluation context for Core Image processing with Metal, OpenGL, or OpenCL.
231    ///
232    /// You use a `CIContext` instance to render a ``CIImage`` instance which represents a graph of image processing operations
233    /// which are built using other Core Image classes, such as ``CIFilter-class``, ``CIKernel``, ``CIColor`` and ``CIImage``.
234    /// You can also use a `CIContext` with the ``CIDetector`` class to analyze images — for example, to detect faces
235    /// or barcodes.
236    ///
237    /// Contexts support automatic color management by performing all processing operations in a working color space.
238    /// This means that unless told otherwise:
239    /// * All input images are color matched from the input's color space to the working space.
240    /// * All renders are color matched from the working space to the destination space.
241    /// (For more information on `CGColorSpace` see
242    /// <doc
243    /// ://com.apple.documentation/documentation/coregraphics/cgcolorspace>)
244    ///
245    /// `CIContext` and ``CIImage`` instances are immutable, so multiple threads can use the same ``CIContext`` instance
246    /// to render ``CIImage`` instances. However, ``CIFilter-class`` instances are mutable and thus cannot be shared safely among
247    /// threads. Each thread must take case not to access or modify a ``CIFilter-class`` instance while it is being used by
248    /// another thread.
249    ///
250    /// The `CIContext` manages various internal state such as `MTLCommandQueue` and caches for compiled kernels
251    /// and intermediate buffers.  For this reason it is not recommended to create many `CIContext` instances.  As a rule,
252    /// it recommended that you create one `CIContext` instance for each view that renders ``CIImage`` or each background task.
253    ///
254    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/cicontext?language=objc)
255    #[unsafe(super(NSObject))]
256    #[derive(Debug, PartialEq, Eq, Hash)]
257    pub struct CIContext;
258);
259
260unsafe impl Send for CIContext {}
261
262unsafe impl Sync for CIContext {}
263
264extern_conformance!(
265    unsafe impl NSObjectProtocol for CIContext {}
266);
267
268impl CIContext {
269    extern_methods!(
270        #[cfg(all(feature = "objc2-core-graphics", feature = "objc2-open-gl"))]
271        #[cfg(target_os = "macos")]
272        /// # Safety
273        ///
274        /// - `cglctx` must be a valid pointer.
275        /// - `pixel_format` must be a valid pointer or null.
276        /// - `options` generic should be of the correct type.
277        #[deprecated = "Core Image OpenGL API deprecated. (Define CI_SILENCE_GL_DEPRECATION to silence these warnings)"]
278        #[unsafe(method(contextWithCGLContext:pixelFormat:colorSpace:options:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn contextWithCGLContext_pixelFormat_colorSpace_options(
281            cglctx: CGLContextObj,
282            pixel_format: CGLPixelFormatObj,
283            color_space: Option<&CGColorSpace>,
284            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
285        ) -> Retained<CIContext>;
286
287        #[cfg(feature = "objc2-open-gl")]
288        #[cfg(target_os = "macos")]
289        /// # Safety
290        ///
291        /// - `cglctx` must be a valid pointer.
292        /// - `pixel_format` must be a valid pointer or null.
293        /// - `options` generic should be of the correct type.
294        #[deprecated = "Core Image OpenGL API deprecated. (Define CI_SILENCE_GL_DEPRECATION to silence these warnings)"]
295        #[unsafe(method(contextWithCGLContext:pixelFormat:options:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn contextWithCGLContext_pixelFormat_options(
298            cglctx: CGLContextObj,
299            pixel_format: CGLPixelFormatObj,
300            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
301        ) -> Retained<CIContext>;
302
303        #[cfg(feature = "objc2-core-graphics")]
304        /// # Safety
305        ///
306        /// `options` generic should be of the correct type.
307        #[unsafe(method(contextWithCGContext:options:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn contextWithCGContext_options(
310            cgctx: &CGContext,
311            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
312        ) -> Retained<CIContext>;
313
314        /// # Safety
315        ///
316        /// `options` generic should be of the correct type.
317        #[unsafe(method(contextWithOptions:))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn contextWithOptions(
320            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
321        ) -> Retained<CIContext>;
322
323        #[unsafe(method(context))]
324        #[unsafe(method_family = none)]
325        pub unsafe fn context() -> Retained<CIContext>;
326
327        /// # Safety
328        ///
329        /// `options` generic should be of the correct type.
330        #[unsafe(method(initWithOptions:))]
331        #[unsafe(method_family = init)]
332        pub unsafe fn initWithOptions(
333            this: Allocated<Self>,
334            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
335        ) -> Retained<Self>;
336
337        #[unsafe(method(init))]
338        #[unsafe(method_family = init)]
339        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
340
341        #[cfg(feature = "objc2-metal")]
342        #[unsafe(method(contextWithMTLDevice:))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn contextWithMTLDevice(
345            device: &ProtocolObject<dyn MTLDevice>,
346        ) -> Retained<CIContext>;
347
348        #[cfg(feature = "objc2-metal")]
349        /// # Safety
350        ///
351        /// `options` generic should be of the correct type.
352        #[unsafe(method(contextWithMTLDevice:options:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn contextWithMTLDevice_options(
355            device: &ProtocolObject<dyn MTLDevice>,
356            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
357        ) -> Retained<CIContext>;
358
359        #[cfg(feature = "objc2-metal")]
360        #[unsafe(method(contextWithMTLCommandQueue:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn contextWithMTLCommandQueue(
363            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
364        ) -> Retained<CIContext>;
365
366        #[cfg(feature = "objc2-metal")]
367        /// # Safety
368        ///
369        /// `options` generic should be of the correct type.
370        #[unsafe(method(contextWithMTLCommandQueue:options:))]
371        #[unsafe(method_family = none)]
372        pub unsafe fn contextWithMTLCommandQueue_options(
373            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
374            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
375        ) -> Retained<CIContext>;
376
377        #[cfg(feature = "objc2-core-graphics")]
378        /// The working color space of the CIContext.
379        ///
380        /// The working color space determines the color space used when executing filter kernels.
381        /// You specify a working color space using the ``kCIContextWorkingColorSpace`` option when creating a ``CIContext``.
382        /// * All input images are color matched from the input's color space to the working space.
383        /// * All renders are color matched from the working space to the destination space.
384        ///
385        /// The property will be `null` if the context was created with color management disabled.
386        ///
387        /// This property is not atomic.
388        ///
389        /// # Safety
390        ///
391        /// This might not be thread-safe.
392        #[unsafe(method(workingColorSpace))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn workingColorSpace(&self) -> Option<Retained<CGColorSpace>>;
395
396        #[cfg(feature = "CIImage")]
397        /// The working pixel format that the CIContext uses for intermediate buffers.
398        ///
399        /// The working format determines the pixel format that Core Image uses to create intermediate buffers for rendering images.
400        /// You specify a working pixel format using the ``kCIContextWorkingFormat`` option when creating a ``CIContext``.
401        ///
402        /// This property is not atomic.
403        ///
404        /// # Safety
405        ///
406        /// This might not be thread-safe.
407        #[unsafe(method(workingFormat))]
408        #[unsafe(method_family = none)]
409        pub unsafe fn workingFormat(&self) -> CIFormat;
410
411        #[cfg(all(feature = "CIImage", feature = "objc2-core-foundation"))]
412        #[deprecated]
413        #[unsafe(method(drawImage:atPoint:fromRect:))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn drawImage_atPoint_fromRect(
416            &self,
417            image: &CIImage,
418            at_point: CGPoint,
419            from_rect: CGRect,
420        );
421
422        #[cfg(all(feature = "CIImage", feature = "objc2-core-foundation"))]
423        #[unsafe(method(drawImage:inRect:fromRect:))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn drawImage_inRect_fromRect(
426            &self,
427            image: &CIImage,
428            in_rect: CGRect,
429            from_rect: CGRect,
430        );
431
432        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
433        /// # Safety
434        ///
435        /// `info` generics must be of the correct type.
436        #[deprecated]
437        #[unsafe(method(createCGLayerWithSize:info:))]
438        // required for soundness, method has `returns_retained` attribute.
439        #[unsafe(method_family = copy)]
440        pub unsafe fn createCGLayerWithSize_info(
441            &self,
442            size: CGSize,
443            info: Option<&CFDictionary>,
444        ) -> Option<Retained<CGLayer>>;
445
446        #[cfg(all(
447            feature = "CIImage",
448            feature = "objc2-core-foundation",
449            feature = "objc2-core-graphics"
450        ))]
451        /// # Safety
452        ///
453        /// `data` must be a valid pointer.
454        #[unsafe(method(render:toBitmap:rowBytes:bounds:format:colorSpace:))]
455        #[unsafe(method_family = none)]
456        pub unsafe fn render_toBitmap_rowBytes_bounds_format_colorSpace(
457            &self,
458            image: &CIImage,
459            data: NonNull<c_void>,
460            row_bytes: isize,
461            bounds: CGRect,
462            format: CIFormat,
463            color_space: Option<&CGColorSpace>,
464        );
465
466        #[cfg(all(
467            feature = "CIImage",
468            feature = "objc2-core-foundation",
469            feature = "objc2-core-graphics",
470            feature = "objc2-io-surface"
471        ))]
472        #[unsafe(method(render:toIOSurface:bounds:colorSpace:))]
473        #[unsafe(method_family = none)]
474        pub unsafe fn render_toIOSurface_bounds_colorSpace(
475            &self,
476            image: &CIImage,
477            surface: &IOSurfaceRef,
478            bounds: CGRect,
479            color_space: Option<&CGColorSpace>,
480        );
481
482        #[cfg(all(feature = "CIImage", feature = "objc2-core-video"))]
483        #[unsafe(method(render:toCVPixelBuffer:))]
484        #[unsafe(method_family = none)]
485        pub unsafe fn render_toCVPixelBuffer(&self, image: &CIImage, buffer: &CVPixelBuffer);
486
487        #[cfg(all(
488            feature = "CIImage",
489            feature = "objc2-core-foundation",
490            feature = "objc2-core-graphics",
491            feature = "objc2-core-video"
492        ))]
493        #[unsafe(method(render:toCVPixelBuffer:bounds:colorSpace:))]
494        #[unsafe(method_family = none)]
495        pub unsafe fn render_toCVPixelBuffer_bounds_colorSpace(
496            &self,
497            image: &CIImage,
498            buffer: &CVPixelBuffer,
499            bounds: CGRect,
500            color_space: Option<&CGColorSpace>,
501        );
502
503        #[cfg(all(
504            feature = "CIImage",
505            feature = "objc2-core-foundation",
506            feature = "objc2-core-graphics",
507            feature = "objc2-metal"
508        ))]
509        /// # Safety
510        ///
511        /// - `texture` may need to be synchronized.
512        /// - `texture` may be unretained, you must ensure it is kept alive while in use.
513        #[unsafe(method(render:toMTLTexture:commandBuffer:bounds:colorSpace:))]
514        #[unsafe(method_family = none)]
515        pub unsafe fn render_toMTLTexture_commandBuffer_bounds_colorSpace(
516            &self,
517            image: &CIImage,
518            texture: &ProtocolObject<dyn MTLTexture>,
519            command_buffer: Option<&ProtocolObject<dyn MTLCommandBuffer>>,
520            bounds: CGRect,
521            color_space: &CGColorSpace,
522        );
523
524        #[unsafe(method(reclaimResources))]
525        #[unsafe(method_family = none)]
526        pub unsafe fn reclaimResources(&self);
527
528        #[unsafe(method(clearCaches))]
529        #[unsafe(method_family = none)]
530        pub unsafe fn clearCaches(&self);
531
532        #[cfg(feature = "objc2-core-foundation")]
533        #[unsafe(method(inputImageMaximumSize))]
534        #[unsafe(method_family = none)]
535        pub unsafe fn inputImageMaximumSize(&self) -> CGSize;
536
537        #[cfg(feature = "objc2-core-foundation")]
538        #[unsafe(method(outputImageMaximumSize))]
539        #[unsafe(method_family = none)]
540        pub unsafe fn outputImageMaximumSize(&self) -> CGSize;
541    );
542}
543
544/// Methods declared on superclass `NSObject`.
545impl CIContext {
546    extern_methods!(
547        #[unsafe(method(new))]
548        #[unsafe(method_family = new)]
549        pub unsafe fn new() -> Retained<Self>;
550    );
551}
552
553/// createCGImage.
554impl CIContext {
555    extern_methods!(
556        #[cfg(all(
557            feature = "CIImage",
558            feature = "objc2-core-foundation",
559            feature = "objc2-core-graphics"
560        ))]
561        /// Creates a Core Graphics image from a region of a Core Image image instance.
562        ///
563        /// The color space of the created `CGImage` will be sRGB unless the receiving ``CIContext``
564        /// was created with a `kCIContextOutputColorSpace` option.
565        ///
566        /// Normally the pixel format of the created CGImage will be 8 bits-per-component.
567        /// It will be 16 bits-per-component float if the above color space is HDR.
568        ///
569        /// - Parameters:
570        /// - image: A ``CIImage`` image instance for which to create a `CGImage`.
571        /// - fromRect: The `CGRect` region of the `image` to use.
572        /// This region relative to the cartesean coordinate system of `image`.
573        /// This region will be intersected with integralized and intersected with `image.extent`.
574        ///
575        /// - Returns:
576        /// Returns a new `CGImage` instance.
577        /// You are responsible for releasing the returned image when you no longer need it.
578        /// The returned value will be `null` if the extent is empty or too big.
579        #[unsafe(method(createCGImage:fromRect:))]
580        // required for soundness, method has `returns_retained` attribute.
581        #[unsafe(method_family = copy)]
582        pub unsafe fn createCGImage_fromRect(
583            &self,
584            image: &CIImage,
585            from_rect: CGRect,
586        ) -> Option<Retained<CGImage>>;
587
588        #[cfg(all(
589            feature = "CIImage",
590            feature = "objc2-core-foundation",
591            feature = "objc2-core-graphics"
592        ))]
593        /// Creates a Core Graphics image from a region of a Core Image image instance
594        /// with an option for controlling the pixel format and color space of the `CGImage`.
595        ///
596        /// - Parameters:
597        /// - image: A ``CIImage`` image instance for which to create a `CGImage`.
598        /// - fromRect: The `CGRect` region of the `image` to use.
599        /// This region relative to the cartesean coordinate system of `image`.
600        /// This region will be intersected with integralized and intersected with `image.extent`.
601        /// - format: A ``CIFormat`` to specify the pixel format of the created `CGImage`.
602        /// For example, if `kCIFormatRGBX16` is specified, then the created `CGImage` will
603        /// be 16 bits-per-component and opaque.
604        /// - colorSpace: The `CGColorSpace` for the output image.
605        /// This color space must have either `CGColorSpaceModel.rgb` or `CGColorSpaceModel.monochrome`
606        /// and be compatible with the specified pixel format.
607        ///
608        /// - Returns:
609        /// Returns a new `CGImage` instance.
610        /// You are responsible for releasing the returned image when you no longer need it.
611        /// The returned value will be `null` if the extent is empty or too big.
612        #[unsafe(method(createCGImage:fromRect:format:colorSpace:))]
613        // required for soundness, method has `returns_retained` attribute.
614        #[unsafe(method_family = copy)]
615        pub unsafe fn createCGImage_fromRect_format_colorSpace(
616            &self,
617            image: &CIImage,
618            from_rect: CGRect,
619            format: CIFormat,
620            color_space: Option<&CGColorSpace>,
621        ) -> Option<Retained<CGImage>>;
622
623        #[cfg(all(
624            feature = "CIImage",
625            feature = "objc2-core-foundation",
626            feature = "objc2-core-graphics"
627        ))]
628        /// Creates a Core Graphics image from a region of a Core Image image instance
629        /// with an option for controlling when the image is rendered.
630        ///
631        /// - Parameters:
632        /// - image: A ``CIImage`` image instance for which to create a `CGImage`.
633        /// - fromRect: The `CGRect` region of the `image` to use.
634        /// This region relative to the cartesean coordinate system of `image`.
635        /// This region will be intersected with integralized and intersected with `image.extent`.
636        /// - format: A ``CIFormat`` to specify the pixel format of the created `CGImage`.
637        /// For example, if `kCIFormatRGBX16` is specified, then the created `CGImage` will
638        /// be 16 bits-per-component and opaque.
639        /// - colorSpace: The `CGColorSpace` for the output image.
640        /// This color space must have either `CGColorSpaceModel.rgb` or `CGColorSpaceModel.monochrome`
641        /// and be compatible with the specified pixel format.
642        /// - deferred: Controls when Core Image renders `image`.
643        /// * True: rendering of `image` is deferred until the created `CGImage` rendered.
644        /// * False: the `image` is rendered immediately.
645        ///
646        /// - Returns:
647        /// Returns a new `CGImage` instance.
648        /// You are responsible for releasing the returned image when you no longer need it.
649        /// The returned value will be `null` if the extent is empty or too big.
650        #[unsafe(method(createCGImage:fromRect:format:colorSpace:deferred:))]
651        // required for soundness, method has `returns_retained` attribute.
652        #[unsafe(method_family = copy)]
653        pub unsafe fn createCGImage_fromRect_format_colorSpace_deferred(
654            &self,
655            image: &CIImage,
656            from_rect: CGRect,
657            format: CIFormat,
658            color_space: Option<&CGColorSpace>,
659            deferred: bool,
660        ) -> Option<Retained<CGImage>>;
661
662        #[cfg(all(
663            feature = "CIImage",
664            feature = "objc2-core-foundation",
665            feature = "objc2-core-graphics"
666        ))]
667        /// Creates a Core Graphics image from a region of a Core Image image instance
668        /// with an option for calculating HDR statistics.
669        ///
670        /// - Parameters:
671        /// - image: A ``CIImage`` image instance for which to create a `CGImage`.
672        /// - fromRect: The `CGRect` region of the `image` to use.
673        /// This region relative to the cartesean coordinate system of `image`.
674        /// This region will be intersected with integralized and intersected with `image.extent`.
675        /// - format: A ``CIFormat`` to specify the pixel format of the created `CGImage`.
676        /// For example, if `kCIFormatRGBX16` is specified, then the created `CGImage` will
677        /// be 16 bits-per-component and opaque.
678        /// - colorSpace: The `CGColorSpace` for the output image.
679        /// This color space must have either `CGColorSpaceModel.rgb` or `CGColorSpaceModel.monochrome`
680        /// and be compatible with the specified pixel format.
681        /// - deferred: Controls when Core Image renders `image`.
682        /// * True: rendering of `image` is deferred until the created `CGImage` rendered.
683        /// * False: the `image` is rendered immediately.
684        /// - calculateHDRStats: Controls if Core Image calculates HDR statistics.
685        /// * True: Core Image will immediately render `image`, calculate the HDR statistics
686        /// and create a `CGImage` that has the calculated values.
687        /// * False:  the created `CGImage` will not have any HDR statistics.
688        ///
689        /// - Returns:
690        /// Returns a new `CGImage` instance.
691        /// You are responsible for releasing the returned image when you no longer need it.
692        /// The returned value will be `null` if the extent is empty or too big.
693        #[unsafe(method(createCGImage:fromRect:format:colorSpace:deferred:calculateHDRStats:))]
694        // required for soundness, method has `returns_retained` attribute.
695        #[unsafe(method_family = copy)]
696        pub unsafe fn createCGImage_fromRect_format_colorSpace_deferred_calculateHDRStats(
697            &self,
698            image: &CIImage,
699            from_rect: CGRect,
700            format: CIFormat,
701            color_space: Option<&CGColorSpace>,
702            deferred: bool,
703            calculate_hdr_stats: bool,
704        ) -> Option<Retained<CGImage>>;
705    );
706}
707
708/// CalculateHDRStats.
709impl CIContext {
710    extern_methods!(
711        #[cfg(feature = "objc2-io-surface")]
712        /// Given an IOSurface, use the receiving Core Image context to calculate its
713        /// HDR statistics (content headroom and content average light level)
714        /// and then update the surface's attachments to store the values.
715        ///
716        /// If the `IOSurface` has a Clean Aperture rectangle then only pixels within
717        /// that rectangle are considered.
718        ///
719        /// - Parameters:
720        /// - surface: A mutable `IOSurfaceRef` for which to calculate and attach statistics.
721        #[unsafe(method(calculateHDRStatsForIOSurface:))]
722        #[unsafe(method_family = none)]
723        pub unsafe fn calculateHDRStatsForIOSurface(&self, surface: &IOSurfaceRef);
724
725        #[cfg(feature = "objc2-core-video")]
726        /// Given a CVPixelBuffer, use the receiving Core Image context to calculate its
727        /// HDR statistics (content headroom and content average light level)
728        /// and then update the buffers's attachments to store the values.
729        ///
730        /// If the `CVPixelBuffer` has a Clean Aperture rectangle then only pixels within
731        /// that rectangle are considered.
732        ///
733        /// - Parameters:
734        /// - buffer: A mutable `CVPixelBuffer` for which to calculate and attach statistics.
735        #[unsafe(method(calculateHDRStatsForCVPixelBuffer:))]
736        #[unsafe(method_family = none)]
737        pub unsafe fn calculateHDRStatsForCVPixelBuffer(&self, buffer: &CVPixelBuffer);
738
739        #[cfg(feature = "objc2-core-graphics")]
740        /// Given a Core Graphics image, use the receiving Core Image context to calculate its
741        /// HDR statistics (content headroom and content average light level)
742        /// and then return a new Core Graphics image that has the calculated values.
743        ///
744        /// - Parameters:
745        /// - cgimage: An immutable `CGImage` for which to calculate statistics.
746        /// - Returns:
747        /// Returns a new `CGImage` instance that has the calculated statistics attached.
748        #[unsafe(method(calculateHDRStatsForCGImage:))]
749        // required for soundness, method has `returns_retained` attribute.
750        #[unsafe(method_family = copy)]
751        pub unsafe fn calculateHDRStatsForCGImage(&self, cgimage: &CGImage) -> Retained<CGImage>;
752
753        #[cfg(feature = "CIImage")]
754        /// Given a Core Image image, use the receiving Core Image context to calculate its
755        /// HDR statistics (content headroom and content average light level)
756        /// and then return a new Core Image image that has the calculated values.
757        ///
758        /// If the image extent is not finite, then nil will be returned.
759        ///
760        /// - Parameters:
761        /// - image: An immutable ``CIImage`` for which to calculate statistics.
762        /// - Returns:
763        /// Returns a new ``CIImage`` instance that has the calculated statistics attached.
764        #[unsafe(method(calculateHDRStatsForImage:))]
765        #[unsafe(method_family = none)]
766        pub unsafe fn calculateHDRStatsForImage(
767            &self,
768            image: &CIImage,
769        ) -> Option<Retained<CIImage>>;
770    );
771}
772
773/// OfflineGPUSupport.
774impl CIContext {
775    extern_methods!(
776        #[unsafe(method(offlineGPUCount))]
777        #[unsafe(method_family = none)]
778        pub unsafe fn offlineGPUCount() -> c_uint;
779
780        #[deprecated = "Core Image OpenGL API deprecated. (Define CI_SILENCE_GL_DEPRECATION to silence these warnings)"]
781        #[unsafe(method(contextForOfflineGPUAtIndex:))]
782        #[unsafe(method_family = none)]
783        pub unsafe fn contextForOfflineGPUAtIndex(index: c_uint) -> Option<Retained<CIContext>>;
784
785        #[cfg(all(feature = "objc2-core-graphics", feature = "objc2-open-gl"))]
786        #[cfg(target_os = "macos")]
787        /// # Safety
788        ///
789        /// - `options` generic should be of the correct type.
790        /// - `shared_context` must be a valid pointer or null.
791        #[deprecated = "Core Image OpenGL API deprecated. (Define CI_SILENCE_GL_DEPRECATION to silence these warnings)"]
792        #[unsafe(method(contextForOfflineGPUAtIndex:colorSpace:options:sharedContext:))]
793        #[unsafe(method_family = none)]
794        pub unsafe fn contextForOfflineGPUAtIndex_colorSpace_options_sharedContext(
795            index: c_uint,
796            color_space: Option<&CGColorSpace>,
797            options: Option<&NSDictionary<CIContextOption, AnyObject>>,
798            shared_context: CGLContextObj,
799        ) -> Option<Retained<CIContext>>;
800    );
801}
802
803/// An enum string type that your code can use to select different options when saving to image representations such as JPEG and HEIF.
804///
805/// Some of the methods that support these options are:
806/// * ``/CIContext/JPEGRepresentationOfImage:colorSpace:options:``
807/// * ``/CIContext/HEIFRepresentationOfImage:format:colorSpace:options:``
808///
809/// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/ciimagerepresentationoption?language=objc)
810// NS_TYPED_ENUM
811pub type CIImageRepresentationOption = NSString;
812
813extern "C" {
814    /// An optional key and value to save additional depth channel information to a JPEG or HEIF representations.
815    ///
816    /// The value for this key needs to be an `AVDepthData` instance.
817    ///
818    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationavdepthdata?language=objc)
819    pub static kCIImageRepresentationAVDepthData: &'static CIImageRepresentationOption;
820}
821
822extern "C" {
823    /// An optional key and value to save additional depth channel information to a JPEG or HEIF.
824    ///
825    /// The value for this key needs to be a monochrome depth ``CIImage`` instance.
826    ///
827    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationdepthimage?language=objc)
828    pub static kCIImageRepresentationDepthImage: &'static CIImageRepresentationOption;
829}
830
831extern "C" {
832    /// An optional key and value to save additional depth channel information to a JPEG or HEIF.
833    ///
834    /// The value for this key needs to be a monochrome disparity ``CIImage`` instance.
835    ///
836    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationdisparityimage?language=objc)
837    pub static kCIImageRepresentationDisparityImage: &'static CIImageRepresentationOption;
838}
839
840extern "C" {
841    /// An optional key and value to save a portrait matte channel information to a JPEG or HEIF.
842    ///
843    /// The value for this key needs to be a an `AVPortraitEffectsMatte` instance.
844    ///
845    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationavportraiteffectsmatte?language=objc)
846    pub static kCIImageRepresentationAVPortraitEffectsMatte: &'static CIImageRepresentationOption;
847}
848
849extern "C" {
850    /// An optional key and value to save a portrait matte channel to a JPEG or HEIF.
851    ///
852    /// The value for this key needs to be a portrait matte ``CIImage`` instance where black pixels
853    /// represent the background region and white pixels represent the primary people in the image.
854    /// The image will be converted to monochrome before it is saved to the JPEG or HEIF.
855    ///
856    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationportraiteffectsmatteimage?language=objc)
857    pub static kCIImageRepresentationPortraitEffectsMatteImage:
858        &'static CIImageRepresentationOption;
859}
860
861extern "C" {
862    /// An optional key and value to save one or more segmentation matte channels to a JPEG or HEIF.
863    ///
864    /// The value for this key needs to be an array of AVSemanticSegmentationMatte instances.
865    ///
866    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationavsemanticsegmentationmattes?language=objc)
867    pub static kCIImageRepresentationAVSemanticSegmentationMattes:
868        &'static CIImageRepresentationOption;
869}
870
871extern "C" {
872    /// An optional key and value to save a skin segmentation channel to a JPEG or HEIF.
873    ///
874    /// The value for this key needs to be a ``CIImage`` instance where white pixels
875    /// represent the areas of person's skin are found in the image.
876    /// The image will be converted to monochrome before it is saved to the JPEG or HEIF.
877    ///
878    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationsemanticsegmentationskinmatteimage?language=objc)
879    pub static kCIImageRepresentationSemanticSegmentationSkinMatteImage:
880        &'static CIImageRepresentationOption;
881}
882
883extern "C" {
884    /// An optional key and value to save a skin segmentation channel to a JPEG or HEIF.
885    ///
886    /// The value for this key needs to be a ``CIImage`` instance where white pixels
887    /// represent the areas of person's head and facial hair are found in the image.
888    /// The image will be converted to monochrome before it is saved to the JPEG or HEIF.
889    ///
890    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationsemanticsegmentationhairmatteimage?language=objc)
891    pub static kCIImageRepresentationSemanticSegmentationHairMatteImage:
892        &'static CIImageRepresentationOption;
893}
894
895extern "C" {
896    /// An optional key and value to save a skin segmentation channel to a JPEG or HEIF.
897    ///
898    /// The value for this key needs to be a ``CIImage`` instance where white pixels
899    /// represent the areas where a person's teeth are found in the image.
900    /// The image will be converted to monochrome before it is saved to the JPEG or HEIF.
901    ///
902    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationsemanticsegmentationteethmatteimage?language=objc)
903    pub static kCIImageRepresentationSemanticSegmentationTeethMatteImage:
904        &'static CIImageRepresentationOption;
905}
906
907extern "C" {
908    /// An optional key and value to save a skin segmentation channel to a JPEG or HEIF.
909    ///
910    /// The value for this key needs to be a ``CIImage`` instance where white pixels
911    /// represent the areas where a person's glasses are found in the image.
912    /// The image will be converted to monochrome before it is saved to the JPEG or HEIF.
913    ///
914    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationsemanticsegmentationglassesmatteimage?language=objc)
915    pub static kCIImageRepresentationSemanticSegmentationGlassesMatteImage:
916        &'static CIImageRepresentationOption;
917}
918
919extern "C" {
920    /// An optional key and value to save a skin segmentation channel to a JPEG or HEIF.
921    ///
922    /// The value for this key needs to be a ``CIImage`` instance where white pixels
923    /// represent the areas where a person's skin are found in the image.
924    /// The image will be converted to monochrome before it is saved to the JPEG or HEIF.
925    ///
926    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationsemanticsegmentationskymatteimage?language=objc)
927    pub static kCIImageRepresentationSemanticSegmentationSkyMatteImage:
928        &'static CIImageRepresentationOption;
929}
930
931extern "C" {
932    /// An optional key and value to save a HDR image using the gain map channel to a JPEG or HEIF.
933    ///
934    /// The value for this key needs to be a HDR CIImage instance.
935    ///
936    /// When provided, Core Image will calculate a gain map auxiliary image
937    /// from the ratio of the HDR image to the primary SDR image.
938    ///
939    /// If the the HDR ``CIImage`` instance has a ``/CIImage/contentHeadroom`` property,
940    /// then that will be used when calculating the HDRGainMap image and metadata.
941    ///
942    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationhdrimage?language=objc)
943    pub static kCIImageRepresentationHDRImage: &'static CIImageRepresentationOption;
944}
945
946extern "C" {
947    /// An optional key and value to save a gain map channel to a JPEG or HEIF.
948    ///
949    /// The value for this key needs to be a monochrome ``CIImage`` instance.
950    ///
951    /// If the ``kCIImageRepresentationHDRGainMapAsRGB`` option it true, then it needs to
952    /// be an RGB ``CIImage`` instance.
953    ///
954    /// The ``/CIImage/properties`` should contain metadata information equivalent to what is returned when
955    /// initializing an image using ``kCIImageAuxiliaryHDRGainMap``.
956    ///
957    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationhdrgainmapimage?language=objc)
958    pub static kCIImageRepresentationHDRGainMapImage: &'static CIImageRepresentationOption;
959}
960
961extern "C" {
962    /// An optional key and value to request the gain map channel to be color instead of monochrome.
963    ///
964    /// This key affects how the gain map image is calculated from the SDR receiver and
965    /// the ``kCIImageRepresentationHDRImage`` image value.
966    ///
967    /// The value for this is a Boolean where:
968    /// * True: the gain map is created as a color ratio between the HDR and SDR images.
969    /// * False: the gain map is created as a brightness ratio between the HDR and SDR images.
970    /// * Not specified: the default behavior False.
971    ///
972    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreimage/kciimagerepresentationhdrgainmapasrgb?language=objc)
973    pub static kCIImageRepresentationHDRGainMapAsRGB: &'static CIImageRepresentationOption;
974}
975
976/// ImageRepresentation.
977impl CIContext {
978    extern_methods!(
979        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
980        /// # Safety
981        ///
982        /// `options` generic should be of the correct type.
983        #[unsafe(method(TIFFRepresentationOfImage:format:colorSpace:options:))]
984        #[unsafe(method_family = none)]
985        pub unsafe fn TIFFRepresentationOfImage_format_colorSpace_options(
986            &self,
987            image: &CIImage,
988            format: CIFormat,
989            color_space: &CGColorSpace,
990            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
991        ) -> Option<Retained<NSData>>;
992
993        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
994        /// # Safety
995        ///
996        /// `options` generic should be of the correct type.
997        #[unsafe(method(JPEGRepresentationOfImage:colorSpace:options:))]
998        #[unsafe(method_family = none)]
999        pub unsafe fn JPEGRepresentationOfImage_colorSpace_options(
1000            &self,
1001            image: &CIImage,
1002            color_space: &CGColorSpace,
1003            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1004        ) -> Option<Retained<NSData>>;
1005
1006        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
1007        /// # Safety
1008        ///
1009        /// `options` generic should be of the correct type.
1010        #[unsafe(method(HEIFRepresentationOfImage:format:colorSpace:options:))]
1011        #[unsafe(method_family = none)]
1012        pub unsafe fn HEIFRepresentationOfImage_format_colorSpace_options(
1013            &self,
1014            image: &CIImage,
1015            format: CIFormat,
1016            color_space: &CGColorSpace,
1017            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1018        ) -> Option<Retained<NSData>>;
1019
1020        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
1021        /// # Safety
1022        ///
1023        /// `options` generic should be of the correct type.
1024        #[unsafe(method(HEIF10RepresentationOfImage:colorSpace:options:error:_))]
1025        #[unsafe(method_family = none)]
1026        pub unsafe fn HEIF10RepresentationOfImage_colorSpace_options_error(
1027            &self,
1028            image: &CIImage,
1029            color_space: &CGColorSpace,
1030            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1031        ) -> Result<Retained<NSData>, Retained<NSError>>;
1032
1033        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
1034        /// # Safety
1035        ///
1036        /// `options` generic should be of the correct type.
1037        #[unsafe(method(PNGRepresentationOfImage:format:colorSpace:options:))]
1038        #[unsafe(method_family = none)]
1039        pub unsafe fn PNGRepresentationOfImage_format_colorSpace_options(
1040            &self,
1041            image: &CIImage,
1042            format: CIFormat,
1043            color_space: &CGColorSpace,
1044            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1045        ) -> Option<Retained<NSData>>;
1046
1047        #[cfg(feature = "CIImage")]
1048        /// # Safety
1049        ///
1050        /// `options` generic should be of the correct type.
1051        #[unsafe(method(OpenEXRRepresentationOfImage:options:error:_))]
1052        #[unsafe(method_family = none)]
1053        pub unsafe fn OpenEXRRepresentationOfImage_options_error(
1054            &self,
1055            image: &CIImage,
1056            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1057        ) -> Result<Retained<NSData>, Retained<NSError>>;
1058
1059        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
1060        /// # Safety
1061        ///
1062        /// `options` generic should be of the correct type.
1063        #[unsafe(method(writeTIFFRepresentationOfImage:toURL:format:colorSpace:options:error:_))]
1064        #[unsafe(method_family = none)]
1065        pub unsafe fn writeTIFFRepresentationOfImage_toURL_format_colorSpace_options_error(
1066            &self,
1067            image: &CIImage,
1068            url: &NSURL,
1069            format: CIFormat,
1070            color_space: &CGColorSpace,
1071            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1072        ) -> Result<(), Retained<NSError>>;
1073
1074        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
1075        /// # Safety
1076        ///
1077        /// `options` generic should be of the correct type.
1078        #[unsafe(method(writePNGRepresentationOfImage:toURL:format:colorSpace:options:error:_))]
1079        #[unsafe(method_family = none)]
1080        pub unsafe fn writePNGRepresentationOfImage_toURL_format_colorSpace_options_error(
1081            &self,
1082            image: &CIImage,
1083            url: &NSURL,
1084            format: CIFormat,
1085            color_space: &CGColorSpace,
1086            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1087        ) -> Result<(), Retained<NSError>>;
1088
1089        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
1090        /// # Safety
1091        ///
1092        /// `options` generic should be of the correct type.
1093        #[unsafe(method(writeJPEGRepresentationOfImage:toURL:colorSpace:options:error:_))]
1094        #[unsafe(method_family = none)]
1095        pub unsafe fn writeJPEGRepresentationOfImage_toURL_colorSpace_options_error(
1096            &self,
1097            image: &CIImage,
1098            url: &NSURL,
1099            color_space: &CGColorSpace,
1100            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1101        ) -> Result<(), Retained<NSError>>;
1102
1103        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
1104        /// # Safety
1105        ///
1106        /// `options` generic should be of the correct type.
1107        #[unsafe(method(writeHEIFRepresentationOfImage:toURL:format:colorSpace:options:error:_))]
1108        #[unsafe(method_family = none)]
1109        pub unsafe fn writeHEIFRepresentationOfImage_toURL_format_colorSpace_options_error(
1110            &self,
1111            image: &CIImage,
1112            url: &NSURL,
1113            format: CIFormat,
1114            color_space: &CGColorSpace,
1115            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1116        ) -> Result<(), Retained<NSError>>;
1117
1118        #[cfg(all(feature = "CIImage", feature = "objc2-core-graphics"))]
1119        /// # Safety
1120        ///
1121        /// `options` generic should be of the correct type.
1122        #[unsafe(method(writeHEIF10RepresentationOfImage:toURL:colorSpace:options:error:_))]
1123        #[unsafe(method_family = none)]
1124        pub unsafe fn writeHEIF10RepresentationOfImage_toURL_colorSpace_options_error(
1125            &self,
1126            image: &CIImage,
1127            url: &NSURL,
1128            color_space: &CGColorSpace,
1129            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1130        ) -> Result<(), Retained<NSError>>;
1131
1132        #[cfg(feature = "CIImage")]
1133        /// # Safety
1134        ///
1135        /// `options` generic should be of the correct type.
1136        #[unsafe(method(writeOpenEXRRepresentationOfImage:toURL:options:error:_))]
1137        #[unsafe(method_family = none)]
1138        pub unsafe fn writeOpenEXRRepresentationOfImage_toURL_options_error(
1139            &self,
1140            image: &CIImage,
1141            url: &NSURL,
1142            options: &NSDictionary<CIImageRepresentationOption, AnyObject>,
1143        ) -> Result<(), Retained<NSError>>;
1144    );
1145}
1146
1147/// CIDepthBlurEffect.
1148impl CIContext {
1149    extern_methods!(
1150        #[cfg(feature = "CIFilter")]
1151        /// # Safety
1152        ///
1153        /// `options` generic should be of the correct type.
1154        #[unsafe(method(depthBlurEffectFilterForImageURL:options:))]
1155        #[unsafe(method_family = none)]
1156        pub unsafe fn depthBlurEffectFilterForImageURL_options(
1157            &self,
1158            url: &NSURL,
1159            options: Option<&NSDictionary>,
1160        ) -> Option<Retained<CIFilter>>;
1161
1162        #[cfg(feature = "CIFilter")]
1163        /// # Safety
1164        ///
1165        /// `options` generic should be of the correct type.
1166        #[unsafe(method(depthBlurEffectFilterForImageData:options:))]
1167        #[unsafe(method_family = none)]
1168        pub unsafe fn depthBlurEffectFilterForImageData_options(
1169            &self,
1170            data: &NSData,
1171            options: Option<&NSDictionary>,
1172        ) -> Option<Retained<CIFilter>>;
1173
1174        #[cfg(all(feature = "CIFilter", feature = "CIImage", feature = "objc2-image-io"))]
1175        /// # Safety
1176        ///
1177        /// `options` generic should be of the correct type.
1178        #[unsafe(method(depthBlurEffectFilterForImage:disparityImage:portraitEffectsMatte:orientation:options:))]
1179        #[unsafe(method_family = none)]
1180        pub unsafe fn depthBlurEffectFilterForImage_disparityImage_portraitEffectsMatte_orientation_options(
1181            &self,
1182            image: &CIImage,
1183            disparity_image: &CIImage,
1184            portrait_effects_matte: Option<&CIImage>,
1185            orientation: CGImagePropertyOrientation,
1186            options: Option<&NSDictionary>,
1187        ) -> Option<Retained<CIFilter>>;
1188
1189        #[cfg(all(feature = "CIFilter", feature = "CIImage", feature = "objc2-image-io"))]
1190        /// # Safety
1191        ///
1192        /// `options` generic should be of the correct type.
1193        #[unsafe(method(depthBlurEffectFilterForImage:disparityImage:portraitEffectsMatte:hairSemanticSegmentation:orientation:options:))]
1194        #[unsafe(method_family = none)]
1195        pub unsafe fn depthBlurEffectFilterForImage_disparityImage_portraitEffectsMatte_hairSemanticSegmentation_orientation_options(
1196            &self,
1197            image: &CIImage,
1198            disparity_image: &CIImage,
1199            portrait_effects_matte: Option<&CIImage>,
1200            hair_semantic_segmentation: Option<&CIImage>,
1201            orientation: CGImagePropertyOrientation,
1202            options: Option<&NSDictionary>,
1203        ) -> Option<Retained<CIFilter>>;
1204
1205        #[cfg(all(feature = "CIFilter", feature = "CIImage", feature = "objc2-image-io"))]
1206        /// # Safety
1207        ///
1208        /// `options` generic should be of the correct type.
1209        #[unsafe(method(depthBlurEffectFilterForImage:disparityImage:portraitEffectsMatte:hairSemanticSegmentation:glassesMatte:gainMap:orientation:options:))]
1210        #[unsafe(method_family = none)]
1211        pub unsafe fn depthBlurEffectFilterForImage_disparityImage_portraitEffectsMatte_hairSemanticSegmentation_glassesMatte_gainMap_orientation_options(
1212            &self,
1213            image: &CIImage,
1214            disparity_image: &CIImage,
1215            portrait_effects_matte: Option<&CIImage>,
1216            hair_semantic_segmentation: Option<&CIImage>,
1217            glasses_matte: Option<&CIImage>,
1218            gain_map: Option<&CIImage>,
1219            orientation: CGImagePropertyOrientation,
1220            options: Option<&NSDictionary>,
1221        ) -> Option<Retained<CIFilter>>;
1222    );
1223}