objc2_image_io/generated/
CGImageDestination.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10#[cfg(feature = "objc2-core-graphics")]
11use objc2_core_graphics::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/imageio/cgimagedestination?language=objc)
16#[doc(alias = "CGImageDestinationRef")]
17#[repr(C)]
18pub struct CGImageDestination {
19    inner: [u8; 0],
20    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23cf_type!(
24    unsafe impl CGImageDestination {}
25);
26#[cfg(feature = "objc2")]
27cf_objc2_type!(
28    unsafe impl RefEncode<"CGImageDestination"> for CGImageDestination {}
29);
30
31extern "C" {
32    /// Properties which may be passed to "CGImageDestinationAddImage"
33    /// * or "CGImageDestinationAddImageFromSource" to effect the output.
34    /// * The values apply to a single image of an image destination. *
35    ///
36    /// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationlossycompressionquality?language=objc)
37    pub static kCGImageDestinationLossyCompressionQuality: &'static CFString;
38}
39
40extern "C" {
41    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationbackgroundcolor?language=objc)
42    pub static kCGImageDestinationBackgroundColor: &'static CFString;
43}
44
45extern "C" {
46    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationimagemaxpixelsize?language=objc)
47    pub static kCGImageDestinationImageMaxPixelSize: &'static CFString;
48}
49
50extern "C" {
51    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationembedthumbnail?language=objc)
52    pub static kCGImageDestinationEmbedThumbnail: &'static CFString;
53}
54
55extern "C" {
56    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationoptimizecolorforsharing?language=objc)
57    pub static kCGImageDestinationOptimizeColorForSharing: &'static CFString;
58}
59
60unsafe impl ConcreteType for CGImageDestination {
61    #[doc(alias = "CGImageDestinationGetTypeID")]
62    #[inline]
63    fn type_id() -> CFTypeID {
64        extern "C-unwind" {
65            fn CGImageDestinationGetTypeID() -> CFTypeID;
66        }
67        unsafe { CGImageDestinationGetTypeID() }
68    }
69}
70
71impl CGImageDestination {
72    #[doc(alias = "CGImageDestinationCopyTypeIdentifiers")]
73    #[inline]
74    pub unsafe fn type_identifiers() -> CFRetained<CFArray> {
75        extern "C-unwind" {
76            fn CGImageDestinationCopyTypeIdentifiers() -> Option<NonNull<CFArray>>;
77        }
78        let ret = unsafe { CGImageDestinationCopyTypeIdentifiers() };
79        let ret =
80            ret.expect("function was marked as returning non-null, but actually returned NULL");
81        unsafe { CFRetained::from_raw(ret) }
82    }
83
84    /// # Safety
85    ///
86    /// `options` generics must be of the correct type.
87    #[doc(alias = "CGImageDestinationCreateWithDataConsumer")]
88    #[cfg(feature = "objc2-core-graphics")]
89    #[inline]
90    pub unsafe fn with_data_consumer(
91        consumer: &CGDataConsumer,
92        r#type: &CFString,
93        count: usize,
94        options: Option<&CFDictionary>,
95    ) -> Option<CFRetained<CGImageDestination>> {
96        extern "C-unwind" {
97            fn CGImageDestinationCreateWithDataConsumer(
98                consumer: &CGDataConsumer,
99                r#type: &CFString,
100                count: usize,
101                options: Option<&CFDictionary>,
102            ) -> Option<NonNull<CGImageDestination>>;
103        }
104        let ret =
105            unsafe { CGImageDestinationCreateWithDataConsumer(consumer, r#type, count, options) };
106        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
107    }
108
109    /// # Safety
110    ///
111    /// `options` generics must be of the correct type.
112    #[doc(alias = "CGImageDestinationCreateWithData")]
113    #[inline]
114    pub unsafe fn with_data(
115        data: &CFMutableData,
116        r#type: &CFString,
117        count: usize,
118        options: Option<&CFDictionary>,
119    ) -> Option<CFRetained<CGImageDestination>> {
120        extern "C-unwind" {
121            fn CGImageDestinationCreateWithData(
122                data: &CFMutableData,
123                r#type: &CFString,
124                count: usize,
125                options: Option<&CFDictionary>,
126            ) -> Option<NonNull<CGImageDestination>>;
127        }
128        let ret = unsafe { CGImageDestinationCreateWithData(data, r#type, count, options) };
129        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
130    }
131
132    /// # Safety
133    ///
134    /// `options` generics must be of the correct type.
135    #[doc(alias = "CGImageDestinationCreateWithURL")]
136    #[inline]
137    pub unsafe fn with_url(
138        url: &CFURL,
139        r#type: &CFString,
140        count: usize,
141        options: Option<&CFDictionary>,
142    ) -> Option<CFRetained<CGImageDestination>> {
143        extern "C-unwind" {
144            fn CGImageDestinationCreateWithURL(
145                url: &CFURL,
146                r#type: &CFString,
147                count: usize,
148                options: Option<&CFDictionary>,
149            ) -> Option<NonNull<CGImageDestination>>;
150        }
151        let ret = unsafe { CGImageDestinationCreateWithURL(url, r#type, count, options) };
152        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
153    }
154
155    /// # Safety
156    ///
157    /// `properties` generics must be of the correct type.
158    #[doc(alias = "CGImageDestinationSetProperties")]
159    #[inline]
160    pub unsafe fn set_properties(&self, properties: Option<&CFDictionary>) {
161        extern "C-unwind" {
162            fn CGImageDestinationSetProperties(
163                idst: &CGImageDestination,
164                properties: Option<&CFDictionary>,
165            );
166        }
167        unsafe { CGImageDestinationSetProperties(self, properties) }
168    }
169
170    /// # Safety
171    ///
172    /// `properties` generics must be of the correct type.
173    #[doc(alias = "CGImageDestinationAddImage")]
174    #[cfg(feature = "objc2-core-graphics")]
175    #[inline]
176    pub unsafe fn add_image(&self, image: &CGImage, properties: Option<&CFDictionary>) {
177        extern "C-unwind" {
178            fn CGImageDestinationAddImage(
179                idst: &CGImageDestination,
180                image: &CGImage,
181                properties: Option<&CFDictionary>,
182            );
183        }
184        unsafe { CGImageDestinationAddImage(self, image, properties) }
185    }
186
187    /// # Safety
188    ///
189    /// `properties` generics must be of the correct type.
190    #[doc(alias = "CGImageDestinationAddImageFromSource")]
191    #[cfg(feature = "CGImageSource")]
192    #[inline]
193    pub unsafe fn add_image_from_source(
194        &self,
195        isrc: &CGImageSource,
196        index: usize,
197        properties: Option<&CFDictionary>,
198    ) {
199        extern "C-unwind" {
200            fn CGImageDestinationAddImageFromSource(
201                idst: &CGImageDestination,
202                isrc: &CGImageSource,
203                index: usize,
204                properties: Option<&CFDictionary>,
205            );
206        }
207        unsafe { CGImageDestinationAddImageFromSource(self, isrc, index, properties) }
208    }
209
210    #[doc(alias = "CGImageDestinationFinalize")]
211    #[inline]
212    pub unsafe fn finalize(&self) -> bool {
213        extern "C-unwind" {
214            fn CGImageDestinationFinalize(idst: &CGImageDestination) -> bool;
215        }
216        unsafe { CGImageDestinationFinalize(self) }
217    }
218
219    /// # Safety
220    ///
221    /// `options` generics must be of the correct type.
222    #[doc(alias = "CGImageDestinationAddImageAndMetadata")]
223    #[cfg(all(feature = "CGImageMetadata", feature = "objc2-core-graphics"))]
224    #[inline]
225    pub unsafe fn add_image_and_metadata(
226        &self,
227        image: &CGImage,
228        metadata: Option<&CGImageMetadata>,
229        options: Option<&CFDictionary>,
230    ) {
231        extern "C-unwind" {
232            fn CGImageDestinationAddImageAndMetadata(
233                idst: &CGImageDestination,
234                image: &CGImage,
235                metadata: Option<&CGImageMetadata>,
236                options: Option<&CFDictionary>,
237            );
238        }
239        unsafe { CGImageDestinationAddImageAndMetadata(self, image, metadata, options) }
240    }
241}
242
243extern "C" {
244    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationpreservegainmap?language=objc)
245    pub static kCGImageDestinationPreserveGainMap: &'static CFString;
246}
247
248extern "C" {
249    /// * Keys which may be used in the 'options' dictionary of
250    /// * "CGImageDestinationCopyImageSource" to effect the output.
251    ///
252    /// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationmetadata?language=objc)
253    pub static kCGImageDestinationMetadata: &'static CFString;
254}
255
256extern "C" {
257    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationmergemetadata?language=objc)
258    pub static kCGImageDestinationMergeMetadata: &'static CFString;
259}
260
261extern "C" {
262    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatashouldexcludexmp?language=objc)
263    pub static kCGImageMetadataShouldExcludeXMP: &'static CFString;
264}
265
266extern "C" {
267    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatashouldexcludegps?language=objc)
268    pub static kCGImageMetadataShouldExcludeGPS: &'static CFString;
269}
270
271extern "C" {
272    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationdatetime?language=objc)
273    pub static kCGImageDestinationDateTime: &'static CFString;
274}
275
276extern "C" {
277    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationorientation?language=objc)
278    pub static kCGImageDestinationOrientation: &'static CFString;
279}
280
281extern "C" {
282    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagepropertyencoder?language=objc)
283    pub static kCGImagePropertyEncoder: &'static CFString;
284}
285
286extern "C" {
287    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagepropertyastcencoder?language=objc)
288    pub static kCGImagePropertyASTCEncoder: &'static CFString;
289}
290
291extern "C" {
292    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagepropertypvrencoder?language=objc)
293    pub static kCGImagePropertyPVREncoder: &'static CFString;
294}
295
296extern "C" {
297    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagepropertybcencoder?language=objc)
298    pub static kCGImagePropertyBCEncoder: &'static CFString;
299}
300
301extern "C" {
302    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagepropertybcformat?language=objc)
303    pub static kCGImagePropertyBCFormat: &'static CFString;
304}
305
306extern "C" {
307    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagepropertyastcblocksize?language=objc)
308    pub static kCGImagePropertyASTCBlockSize: &'static CFString;
309}
310
311extern "C" {
312    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagepropertyastcblocksize4x4?language=objc)
313    pub static kCGImagePropertyASTCBlockSize4x4: &'static CFString;
314}
315
316extern "C" {
317    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagepropertyastcblocksize8x8?language=objc)
318    pub static kCGImagePropertyASTCBlockSize8x8: &'static CFString;
319}
320
321impl CGImageDestination {
322    /// # Safety
323    ///
324    /// - `options` generics must be of the correct type.
325    /// - `err` must be a valid pointer or null.
326    #[doc(alias = "CGImageDestinationCopyImageSource")]
327    #[cfg(feature = "CGImageSource")]
328    #[inline]
329    pub unsafe fn copy_image_source(
330        &self,
331        isrc: &CGImageSource,
332        options: Option<&CFDictionary>,
333        err: *mut *mut CFError,
334    ) -> bool {
335        extern "C-unwind" {
336            fn CGImageDestinationCopyImageSource(
337                idst: &CGImageDestination,
338                isrc: &CGImageSource,
339                options: Option<&CFDictionary>,
340                err: *mut *mut CFError,
341            ) -> bool;
342        }
343        unsafe { CGImageDestinationCopyImageSource(self, isrc, options, err) }
344    }
345
346    /// # Safety
347    ///
348    /// `auxiliary_data_info_dictionary` generics must be of the correct type.
349    #[doc(alias = "CGImageDestinationAddAuxiliaryDataInfo")]
350    #[inline]
351    pub unsafe fn add_auxiliary_data_info(
352        &self,
353        auxiliary_image_data_type: &CFString,
354        auxiliary_data_info_dictionary: &CFDictionary,
355    ) {
356        extern "C-unwind" {
357            fn CGImageDestinationAddAuxiliaryDataInfo(
358                idst: &CGImageDestination,
359                auxiliary_image_data_type: &CFString,
360                auxiliary_data_info_dictionary: &CFDictionary,
361            );
362        }
363        unsafe {
364            CGImageDestinationAddAuxiliaryDataInfo(
365                self,
366                auxiliary_image_data_type,
367                auxiliary_data_info_dictionary,
368            )
369        }
370    }
371}
372
373extern "C" {
374    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencoderequest?language=objc)
375    pub static kCGImageDestinationEncodeRequest: &'static CFString;
376}
377
378extern "C" {
379    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodetosdr?language=objc)
380    pub static kCGImageDestinationEncodeToSDR: &'static CFString;
381}
382
383extern "C" {
384    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodetoisohdr?language=objc)
385    pub static kCGImageDestinationEncodeToISOHDR: &'static CFString;
386}
387
388extern "C" {
389    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodetoisogainmap?language=objc)
390    pub static kCGImageDestinationEncodeToISOGainmap: &'static CFString;
391}
392
393extern "C" {
394    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencoderequestoptions?language=objc)
395    pub static kCGImageDestinationEncodeRequestOptions: &'static CFString;
396}
397
398extern "C" {
399    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodebaseissdr?language=objc)
400    pub static kCGImageDestinationEncodeBaseIsSDR: &'static CFString;
401}
402
403extern "C" {
404    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodetonemapmode?language=objc)
405    pub static kCGImageDestinationEncodeTonemapMode: &'static CFString;
406}
407
408extern "C" {
409    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodeisbaseimage?language=objc)
410    pub static kCGImageDestinationEncodeIsBaseImage: &'static CFString;
411}
412
413extern "C" {
414    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodebasecolorspace?language=objc)
415    pub static kCGImageDestinationEncodeBaseColorSpace: &'static CFString;
416}
417
418extern "C" {
419    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodebasepixelformatrequest?language=objc)
420    pub static kCGImageDestinationEncodeBasePixelFormatRequest: &'static CFString;
421}
422
423extern "C" {
424    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodegenerategainmapwithbaseimage?language=objc)
425    pub static kCGImageDestinationEncodeGenerateGainMapWithBaseImage: &'static CFString;
426}
427
428extern "C" {
429    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodegainmappixelformatrequest?language=objc)
430    pub static kCGImageDestinationEncodeGainMapPixelFormatRequest: &'static CFString;
431}
432
433extern "C" {
434    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodegainmapsubsamplefactor?language=objc)
435    pub static kCGImageDestinationEncodeGainMapSubsampleFactor: &'static CFString;
436}
437
438extern "C" {
439    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagedestinationencodealternatecolorspace?language=objc)
440    pub static kCGImageDestinationEncodeAlternateColorSpace: &'static CFString;
441}
442
443#[deprecated = "renamed to `CGImageDestination::type_identifiers`"]
444#[inline]
445pub unsafe extern "C-unwind" fn CGImageDestinationCopyTypeIdentifiers() -> CFRetained<CFArray> {
446    extern "C-unwind" {
447        fn CGImageDestinationCopyTypeIdentifiers() -> Option<NonNull<CFArray>>;
448    }
449    let ret = unsafe { CGImageDestinationCopyTypeIdentifiers() };
450    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
451    unsafe { CFRetained::from_raw(ret) }
452}
453
454#[cfg(feature = "objc2-core-graphics")]
455#[deprecated = "renamed to `CGImageDestination::with_data_consumer`"]
456#[inline]
457pub unsafe extern "C-unwind" fn CGImageDestinationCreateWithDataConsumer(
458    consumer: &CGDataConsumer,
459    r#type: &CFString,
460    count: usize,
461    options: Option<&CFDictionary>,
462) -> Option<CFRetained<CGImageDestination>> {
463    extern "C-unwind" {
464        fn CGImageDestinationCreateWithDataConsumer(
465            consumer: &CGDataConsumer,
466            r#type: &CFString,
467            count: usize,
468            options: Option<&CFDictionary>,
469        ) -> Option<NonNull<CGImageDestination>>;
470    }
471    let ret = unsafe { CGImageDestinationCreateWithDataConsumer(consumer, r#type, count, options) };
472    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
473}
474
475#[deprecated = "renamed to `CGImageDestination::with_data`"]
476#[inline]
477pub unsafe extern "C-unwind" fn CGImageDestinationCreateWithData(
478    data: &CFMutableData,
479    r#type: &CFString,
480    count: usize,
481    options: Option<&CFDictionary>,
482) -> Option<CFRetained<CGImageDestination>> {
483    extern "C-unwind" {
484        fn CGImageDestinationCreateWithData(
485            data: &CFMutableData,
486            r#type: &CFString,
487            count: usize,
488            options: Option<&CFDictionary>,
489        ) -> Option<NonNull<CGImageDestination>>;
490    }
491    let ret = unsafe { CGImageDestinationCreateWithData(data, r#type, count, options) };
492    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
493}
494
495#[deprecated = "renamed to `CGImageDestination::with_url`"]
496#[inline]
497pub unsafe extern "C-unwind" fn CGImageDestinationCreateWithURL(
498    url: &CFURL,
499    r#type: &CFString,
500    count: usize,
501    options: Option<&CFDictionary>,
502) -> Option<CFRetained<CGImageDestination>> {
503    extern "C-unwind" {
504        fn CGImageDestinationCreateWithURL(
505            url: &CFURL,
506            r#type: &CFString,
507            count: usize,
508            options: Option<&CFDictionary>,
509        ) -> Option<NonNull<CGImageDestination>>;
510    }
511    let ret = unsafe { CGImageDestinationCreateWithURL(url, r#type, count, options) };
512    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
513}
514
515extern "C-unwind" {
516    #[deprecated = "renamed to `CGImageDestination::set_properties`"]
517    pub fn CGImageDestinationSetProperties(
518        idst: &CGImageDestination,
519        properties: Option<&CFDictionary>,
520    );
521}
522
523extern "C-unwind" {
524    #[cfg(feature = "objc2-core-graphics")]
525    #[deprecated = "renamed to `CGImageDestination::add_image`"]
526    pub fn CGImageDestinationAddImage(
527        idst: &CGImageDestination,
528        image: &CGImage,
529        properties: Option<&CFDictionary>,
530    );
531}
532
533extern "C-unwind" {
534    #[cfg(feature = "CGImageSource")]
535    #[deprecated = "renamed to `CGImageDestination::add_image_from_source`"]
536    pub fn CGImageDestinationAddImageFromSource(
537        idst: &CGImageDestination,
538        isrc: &CGImageSource,
539        index: usize,
540        properties: Option<&CFDictionary>,
541    );
542}
543
544extern "C-unwind" {
545    #[deprecated = "renamed to `CGImageDestination::finalize`"]
546    pub fn CGImageDestinationFinalize(idst: &CGImageDestination) -> bool;
547}
548
549extern "C-unwind" {
550    #[cfg(all(feature = "CGImageMetadata", feature = "objc2-core-graphics"))]
551    #[deprecated = "renamed to `CGImageDestination::add_image_and_metadata`"]
552    pub fn CGImageDestinationAddImageAndMetadata(
553        idst: &CGImageDestination,
554        image: &CGImage,
555        metadata: Option<&CGImageMetadata>,
556        options: Option<&CFDictionary>,
557    );
558}
559
560extern "C-unwind" {
561    #[cfg(feature = "CGImageSource")]
562    #[deprecated = "renamed to `CGImageDestination::copy_image_source`"]
563    pub fn CGImageDestinationCopyImageSource(
564        idst: &CGImageDestination,
565        isrc: &CGImageSource,
566        options: Option<&CFDictionary>,
567        err: *mut *mut CFError,
568    ) -> bool;
569}
570
571extern "C-unwind" {
572    #[deprecated = "renamed to `CGImageDestination::add_auxiliary_data_info`"]
573    pub fn CGImageDestinationAddAuxiliaryDataInfo(
574        idst: &CGImageDestination,
575        auxiliary_image_data_type: &CFString,
576        auxiliary_data_info_dictionary: &CFDictionary,
577    );
578}