objc2_ui_kit/generated/
UIImage.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-image")]
11#[cfg(not(target_os = "watchos"))]
12use objc2_core_image::*;
13use objc2_foundation::*;
14
15use crate::*;
16
17/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiimageorientation?language=objc)
18// NS_ENUM
19#[repr(transparent)]
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
21pub struct UIImageOrientation(pub NSInteger);
22impl UIImageOrientation {
23    #[doc(alias = "UIImageOrientationUp")]
24    pub const Up: Self = Self(0);
25    #[doc(alias = "UIImageOrientationDown")]
26    pub const Down: Self = Self(1);
27    #[doc(alias = "UIImageOrientationLeft")]
28    pub const Left: Self = Self(2);
29    #[doc(alias = "UIImageOrientationRight")]
30    pub const Right: Self = Self(3);
31    #[doc(alias = "UIImageOrientationUpMirrored")]
32    pub const UpMirrored: Self = Self(4);
33    #[doc(alias = "UIImageOrientationDownMirrored")]
34    pub const DownMirrored: Self = Self(5);
35    #[doc(alias = "UIImageOrientationLeftMirrored")]
36    pub const LeftMirrored: Self = Self(6);
37    #[doc(alias = "UIImageOrientationRightMirrored")]
38    pub const RightMirrored: Self = Self(7);
39}
40
41unsafe impl Encode for UIImageOrientation {
42    const ENCODING: Encoding = NSInteger::ENCODING;
43}
44
45unsafe impl RefEncode for UIImageOrientation {
46    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
47}
48
49/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiimageresizingmode?language=objc)
50// NS_ENUM
51#[repr(transparent)]
52#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
53pub struct UIImageResizingMode(pub NSInteger);
54impl UIImageResizingMode {}
55
56unsafe impl Encode for UIImageResizingMode {
57    const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for UIImageResizingMode {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiimagerenderingmode?language=objc)
65// NS_ENUM
66#[repr(transparent)]
67#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
68pub struct UIImageRenderingMode(pub NSInteger);
69impl UIImageRenderingMode {
70    #[doc(alias = "UIImageRenderingModeAutomatic")]
71    pub const Automatic: Self = Self(0);
72    #[doc(alias = "UIImageRenderingModeAlwaysOriginal")]
73    pub const AlwaysOriginal: Self = Self(1);
74    #[doc(alias = "UIImageRenderingModeAlwaysTemplate")]
75    pub const AlwaysTemplate: Self = Self(2);
76}
77
78unsafe impl Encode for UIImageRenderingMode {
79    const ENCODING: Encoding = NSInteger::ENCODING;
80}
81
82unsafe impl RefEncode for UIImageRenderingMode {
83    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
84}
85
86extern_class!(
87    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiimage?language=objc)
88    #[unsafe(super(NSObject))]
89    #[derive(Debug, PartialEq, Eq, Hash)]
90    pub struct UIImage;
91);
92
93unsafe impl Send for UIImage {}
94
95unsafe impl Sync for UIImage {}
96
97extern_conformance!(
98    unsafe impl NSCoding for UIImage {}
99);
100
101extern_conformance!(
102    unsafe impl NSObjectProtocol for UIImage {}
103);
104
105extern_conformance!(
106    unsafe impl NSSecureCoding for UIImage {}
107);
108
109impl UIImage {
110    extern_methods!(
111        #[unsafe(method(systemImageNamed:))]
112        #[unsafe(method_family = none)]
113        pub fn systemImageNamed(name: &NSString) -> Option<Retained<UIImage>>;
114
115        #[cfg(feature = "UIImageConfiguration")]
116        #[unsafe(method(systemImageNamed:withConfiguration:))]
117        #[unsafe(method_family = none)]
118        pub fn systemImageNamed_withConfiguration(
119            name: &NSString,
120            configuration: Option<&UIImageConfiguration>,
121        ) -> Option<Retained<UIImage>>;
122
123        #[cfg(feature = "UITraitCollection")]
124        #[unsafe(method(systemImageNamed:compatibleWithTraitCollection:))]
125        #[unsafe(method_family = none)]
126        pub fn systemImageNamed_compatibleWithTraitCollection(
127            name: &NSString,
128            trait_collection: Option<&UITraitCollection>,
129        ) -> Option<Retained<UIImage>>;
130
131        #[cfg(feature = "UIImageConfiguration")]
132        /// Retrieve a system-provided image with the specified name and variable value (between 0 and 1).
133        ///
134        /// This will only return system-provided images. If you want a custom image as defined in your own catalogs,
135        /// you should use
136        /// `+imageNamed:inBundle:variableValue:withConfiguration:.`
137        /// Returns
138        /// `nil`if an image with specified name doesn't exist.
139        #[unsafe(method(systemImageNamed:variableValue:withConfiguration:))]
140        #[unsafe(method_family = none)]
141        pub fn systemImageNamed_variableValue_withConfiguration(
142            name: &NSString,
143            value: c_double,
144            configuration: Option<&UIImageConfiguration>,
145        ) -> Option<Retained<UIImage>>;
146
147        #[unsafe(method(imageNamed:))]
148        #[unsafe(method_family = none)]
149        pub fn imageNamed(name: &NSString) -> Option<Retained<UIImage>>;
150
151        #[cfg(feature = "UIImageConfiguration")]
152        #[unsafe(method(imageNamed:inBundle:withConfiguration:))]
153        #[unsafe(method_family = none)]
154        pub fn imageNamed_inBundle_withConfiguration(
155            name: &NSString,
156            bundle: Option<&NSBundle>,
157            configuration: Option<&UIImageConfiguration>,
158        ) -> Option<Retained<UIImage>>;
159
160        #[cfg(feature = "UITraitCollection")]
161        #[unsafe(method(imageNamed:inBundle:compatibleWithTraitCollection:))]
162        #[unsafe(method_family = none)]
163        pub fn imageNamed_inBundle_compatibleWithTraitCollection(
164            name: &NSString,
165            bundle: Option<&NSBundle>,
166            trait_collection: Option<&UITraitCollection>,
167        ) -> Option<Retained<UIImage>>;
168
169        #[cfg(feature = "UIImageConfiguration")]
170        /// Retrieve a image with the specified name and variable value (between 0 and 1).
171        ///
172        /// This will only return custom images defined in your own catalogs. If you want a system-provided image,
173        /// you should use
174        /// `+systemImageNamed:variableValue:withConfiguration:.`
175        /// Returns
176        /// `nil`if an image with specified name doesn't exist.
177        #[unsafe(method(imageNamed:inBundle:variableValue:withConfiguration:))]
178        #[unsafe(method_family = none)]
179        pub fn imageNamed_inBundle_variableValue_withConfiguration(
180            name: &NSString,
181            bundle: Option<&NSBundle>,
182            value: c_double,
183            configuration: Option<&UIImageConfiguration>,
184        ) -> Option<Retained<UIImage>>;
185
186        #[unsafe(method(imageWithContentsOfFile:))]
187        #[unsafe(method_family = none)]
188        pub fn imageWithContentsOfFile(path: &NSString) -> Option<Retained<UIImage>>;
189
190        #[unsafe(method(imageWithData:))]
191        #[unsafe(method_family = none)]
192        pub fn imageWithData(data: &NSData) -> Option<Retained<UIImage>>;
193
194        #[cfg(feature = "objc2-core-foundation")]
195        #[unsafe(method(imageWithData:scale:))]
196        #[unsafe(method_family = none)]
197        pub fn imageWithData_scale(data: &NSData, scale: CGFloat) -> Option<Retained<UIImage>>;
198
199        #[cfg(feature = "objc2-core-graphics")]
200        #[unsafe(method(imageWithCGImage:))]
201        #[unsafe(method_family = none)]
202        pub fn imageWithCGImage(cg_image: &CGImage) -> Retained<UIImage>;
203
204        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
205        #[unsafe(method(imageWithCGImage:scale:orientation:))]
206        #[unsafe(method_family = none)]
207        pub fn imageWithCGImage_scale_orientation(
208            cg_image: &CGImage,
209            scale: CGFloat,
210            orientation: UIImageOrientation,
211        ) -> Retained<UIImage>;
212
213        #[cfg(feature = "objc2-core-image")]
214        #[cfg(not(target_os = "watchos"))]
215        #[unsafe(method(imageWithCIImage:))]
216        #[unsafe(method_family = none)]
217        pub fn imageWithCIImage(ci_image: &CIImage) -> Retained<UIImage>;
218
219        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-image"))]
220        #[cfg(not(target_os = "watchos"))]
221        #[unsafe(method(imageWithCIImage:scale:orientation:))]
222        #[unsafe(method_family = none)]
223        pub fn imageWithCIImage_scale_orientation(
224            ci_image: &CIImage,
225            scale: CGFloat,
226            orientation: UIImageOrientation,
227        ) -> Retained<UIImage>;
228
229        #[unsafe(method(initWithContentsOfFile:))]
230        #[unsafe(method_family = init)]
231        pub fn initWithContentsOfFile(
232            this: Allocated<Self>,
233            path: &NSString,
234        ) -> Option<Retained<Self>>;
235
236        #[unsafe(method(initWithData:))]
237        #[unsafe(method_family = init)]
238        pub fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;
239
240        #[cfg(feature = "objc2-core-foundation")]
241        #[unsafe(method(initWithData:scale:))]
242        #[unsafe(method_family = init)]
243        pub fn initWithData_scale(
244            this: Allocated<Self>,
245            data: &NSData,
246            scale: CGFloat,
247        ) -> Option<Retained<Self>>;
248
249        #[cfg(feature = "objc2-core-graphics")]
250        #[unsafe(method(initWithCGImage:))]
251        #[unsafe(method_family = init)]
252        pub fn initWithCGImage(this: Allocated<Self>, cg_image: &CGImage) -> Retained<Self>;
253
254        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
255        #[unsafe(method(initWithCGImage:scale:orientation:))]
256        #[unsafe(method_family = init)]
257        pub fn initWithCGImage_scale_orientation(
258            this: Allocated<Self>,
259            cg_image: &CGImage,
260            scale: CGFloat,
261            orientation: UIImageOrientation,
262        ) -> Retained<Self>;
263
264        #[cfg(feature = "objc2-core-image")]
265        #[cfg(not(target_os = "watchos"))]
266        #[unsafe(method(initWithCIImage:))]
267        #[unsafe(method_family = init)]
268        pub fn initWithCIImage(this: Allocated<Self>, ci_image: &CIImage) -> Retained<Self>;
269
270        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-image"))]
271        #[cfg(not(target_os = "watchos"))]
272        #[unsafe(method(initWithCIImage:scale:orientation:))]
273        #[unsafe(method_family = init)]
274        pub fn initWithCIImage_scale_orientation(
275            this: Allocated<Self>,
276            ci_image: &CIImage,
277            scale: CGFloat,
278            orientation: UIImageOrientation,
279        ) -> Retained<Self>;
280
281        #[cfg(feature = "objc2-core-foundation")]
282        /// This property is not atomic.
283        ///
284        /// # Safety
285        ///
286        /// This might not be thread-safe.
287        #[unsafe(method(size))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn size(&self) -> CGSize;
290
291        #[cfg(feature = "objc2-core-graphics")]
292        /// This property is not atomic.
293        ///
294        /// # Safety
295        ///
296        /// This might not be thread-safe.
297        #[unsafe(method(CGImage))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn CGImage(&self) -> Option<Retained<CGImage>>;
300
301        #[cfg(feature = "objc2-core-image")]
302        #[cfg(not(target_os = "watchos"))]
303        /// This property is not atomic.
304        ///
305        /// # Safety
306        ///
307        /// This might not be thread-safe.
308        #[unsafe(method(CIImage))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn CIImage(&self) -> Option<Retained<CIImage>>;
311
312        /// This property is not atomic.
313        ///
314        /// # Safety
315        ///
316        /// This might not be thread-safe.
317        #[unsafe(method(imageOrientation))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn imageOrientation(&self) -> UIImageOrientation;
320
321        #[cfg(feature = "objc2-core-foundation")]
322        /// This property is not atomic.
323        ///
324        /// # Safety
325        ///
326        /// This might not be thread-safe.
327        #[unsafe(method(scale))]
328        #[unsafe(method_family = none)]
329        pub unsafe fn scale(&self) -> CGFloat;
330
331        /// This property is not atomic.
332        ///
333        /// # Safety
334        ///
335        /// This might not be thread-safe.
336        #[unsafe(method(isSymbolImage))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn isSymbolImage(&self) -> bool;
339
340        #[unsafe(method(animatedImageNamed:duration:))]
341        #[unsafe(method_family = none)]
342        pub fn animatedImageNamed_duration(
343            name: &NSString,
344            duration: NSTimeInterval,
345        ) -> Option<Retained<UIImage>>;
346
347        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
348        #[unsafe(method(animatedResizableImageNamed:capInsets:duration:))]
349        #[unsafe(method_family = none)]
350        pub fn animatedResizableImageNamed_capInsets_duration(
351            name: &NSString,
352            cap_insets: UIEdgeInsets,
353            duration: NSTimeInterval,
354        ) -> Option<Retained<UIImage>>;
355
356        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
357        #[unsafe(method(animatedResizableImageNamed:capInsets:resizingMode:duration:))]
358        #[unsafe(method_family = none)]
359        pub fn animatedResizableImageNamed_capInsets_resizingMode_duration(
360            name: &NSString,
361            cap_insets: UIEdgeInsets,
362            resizing_mode: UIImageResizingMode,
363            duration: NSTimeInterval,
364        ) -> Option<Retained<UIImage>>;
365
366        #[unsafe(method(animatedImageWithImages:duration:))]
367        #[unsafe(method_family = none)]
368        pub fn animatedImageWithImages_duration(
369            images: &NSArray<UIImage>,
370            duration: NSTimeInterval,
371        ) -> Option<Retained<UIImage>>;
372
373        /// This property is not atomic.
374        ///
375        /// # Safety
376        ///
377        /// This might not be thread-safe.
378        #[unsafe(method(images))]
379        #[unsafe(method_family = none)]
380        pub unsafe fn images(&self) -> Option<Retained<NSArray<UIImage>>>;
381
382        /// This property is not atomic.
383        ///
384        /// # Safety
385        ///
386        /// This might not be thread-safe.
387        #[unsafe(method(duration))]
388        #[unsafe(method_family = none)]
389        pub unsafe fn duration(&self) -> NSTimeInterval;
390
391        #[cfg(feature = "objc2-core-foundation")]
392        #[unsafe(method(drawAtPoint:))]
393        #[unsafe(method_family = none)]
394        pub fn drawAtPoint(&self, point: CGPoint);
395
396        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
397        #[unsafe(method(drawAtPoint:blendMode:alpha:))]
398        #[unsafe(method_family = none)]
399        pub fn drawAtPoint_blendMode_alpha(
400            &self,
401            point: CGPoint,
402            blend_mode: CGBlendMode,
403            alpha: CGFloat,
404        );
405
406        #[cfg(feature = "objc2-core-foundation")]
407        #[unsafe(method(drawInRect:))]
408        #[unsafe(method_family = none)]
409        pub fn drawInRect(&self, rect: CGRect);
410
411        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
412        #[unsafe(method(drawInRect:blendMode:alpha:))]
413        #[unsafe(method_family = none)]
414        pub fn drawInRect_blendMode_alpha(
415            &self,
416            rect: CGRect,
417            blend_mode: CGBlendMode,
418            alpha: CGFloat,
419        );
420
421        #[cfg(feature = "objc2-core-foundation")]
422        #[unsafe(method(drawAsPatternInRect:))]
423        #[unsafe(method_family = none)]
424        pub fn drawAsPatternInRect(&self, rect: CGRect);
425
426        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
427        #[unsafe(method(resizableImageWithCapInsets:))]
428        #[unsafe(method_family = none)]
429        pub fn resizableImageWithCapInsets(&self, cap_insets: UIEdgeInsets) -> Retained<UIImage>;
430
431        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
432        #[unsafe(method(resizableImageWithCapInsets:resizingMode:))]
433        #[unsafe(method_family = none)]
434        pub fn resizableImageWithCapInsets_resizingMode(
435            &self,
436            cap_insets: UIEdgeInsets,
437            resizing_mode: UIImageResizingMode,
438        ) -> Retained<UIImage>;
439
440        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
441        /// This property is not atomic.
442        ///
443        /// # Safety
444        ///
445        /// This might not be thread-safe.
446        #[unsafe(method(capInsets))]
447        #[unsafe(method_family = none)]
448        pub unsafe fn capInsets(&self) -> UIEdgeInsets;
449
450        /// This property is not atomic.
451        ///
452        /// # Safety
453        ///
454        /// This might not be thread-safe.
455        #[unsafe(method(resizingMode))]
456        #[unsafe(method_family = none)]
457        pub unsafe fn resizingMode(&self) -> UIImageResizingMode;
458
459        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
460        #[unsafe(method(imageWithAlignmentRectInsets:))]
461        #[unsafe(method_family = none)]
462        pub fn imageWithAlignmentRectInsets(
463            &self,
464            alignment_insets: UIEdgeInsets,
465        ) -> Retained<UIImage>;
466
467        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
468        /// This property is not atomic.
469        ///
470        /// # Safety
471        ///
472        /// This might not be thread-safe.
473        #[unsafe(method(alignmentRectInsets))]
474        #[unsafe(method_family = none)]
475        pub unsafe fn alignmentRectInsets(&self) -> UIEdgeInsets;
476
477        #[unsafe(method(imageWithRenderingMode:))]
478        #[unsafe(method_family = none)]
479        pub fn imageWithRenderingMode(
480            &self,
481            rendering_mode: UIImageRenderingMode,
482        ) -> Retained<UIImage>;
483
484        /// This property is not atomic.
485        ///
486        /// # Safety
487        ///
488        /// This might not be thread-safe.
489        #[unsafe(method(renderingMode))]
490        #[unsafe(method_family = none)]
491        pub unsafe fn renderingMode(&self) -> UIImageRenderingMode;
492
493        #[cfg(all(feature = "UIGraphicsImageRenderer", feature = "UIGraphicsRenderer"))]
494        /// This property is not atomic.
495        ///
496        /// # Safety
497        ///
498        /// This might not be thread-safe.
499        #[unsafe(method(imageRendererFormat))]
500        #[unsafe(method_family = none)]
501        pub unsafe fn imageRendererFormat(&self) -> Retained<UIGraphicsImageRendererFormat>;
502
503        #[cfg(feature = "UITraitCollection")]
504        /// This property is not atomic.
505        ///
506        /// # Safety
507        ///
508        /// This might not be thread-safe.
509        #[unsafe(method(traitCollection))]
510        #[unsafe(method_family = none)]
511        pub unsafe fn traitCollection(&self) -> Retained<UITraitCollection>;
512
513        #[cfg(feature = "UIImageAsset")]
514        /// This property is not atomic.
515        ///
516        /// # Safety
517        ///
518        /// This might not be thread-safe.
519        #[unsafe(method(imageAsset))]
520        #[unsafe(method_family = none)]
521        pub unsafe fn imageAsset(&self) -> Option<Retained<UIImageAsset>>;
522
523        #[unsafe(method(imageFlippedForRightToLeftLayoutDirection))]
524        #[unsafe(method_family = none)]
525        pub fn imageFlippedForRightToLeftLayoutDirection(&self) -> Retained<UIImage>;
526
527        /// This property is not atomic.
528        ///
529        /// # Safety
530        ///
531        /// This might not be thread-safe.
532        #[unsafe(method(flipsForRightToLeftLayoutDirection))]
533        #[unsafe(method_family = none)]
534        pub unsafe fn flipsForRightToLeftLayoutDirection(&self) -> bool;
535
536        #[unsafe(method(imageWithHorizontallyFlippedOrientation))]
537        #[unsafe(method_family = none)]
538        pub fn imageWithHorizontallyFlippedOrientation(&self) -> Retained<UIImage>;
539
540        #[cfg(feature = "objc2-core-foundation")]
541        /// This property is not atomic.
542        ///
543        /// # Safety
544        ///
545        /// This might not be thread-safe.
546        #[unsafe(method(baselineOffsetFromBottom))]
547        #[unsafe(method_family = none)]
548        pub unsafe fn baselineOffsetFromBottom(&self) -> CGFloat;
549
550        /// This property is not atomic.
551        ///
552        /// # Safety
553        ///
554        /// This might not be thread-safe.
555        #[unsafe(method(hasBaseline))]
556        #[unsafe(method_family = none)]
557        pub unsafe fn hasBaseline(&self) -> bool;
558
559        #[cfg(feature = "objc2-core-foundation")]
560        #[unsafe(method(imageWithBaselineOffsetFromBottom:))]
561        #[unsafe(method_family = none)]
562        pub fn imageWithBaselineOffsetFromBottom(
563            &self,
564            baseline_offset: CGFloat,
565        ) -> Retained<UIImage>;
566
567        #[unsafe(method(imageWithoutBaseline))]
568        #[unsafe(method_family = none)]
569        pub fn imageWithoutBaseline(&self) -> Retained<UIImage>;
570
571        #[cfg(feature = "UIImageConfiguration")]
572        /// This property is not atomic.
573        ///
574        /// # Safety
575        ///
576        /// This might not be thread-safe.
577        #[unsafe(method(configuration))]
578        #[unsafe(method_family = none)]
579        pub unsafe fn configuration(&self) -> Option<Retained<UIImageConfiguration>>;
580
581        #[cfg(feature = "UIImageConfiguration")]
582        #[unsafe(method(imageWithConfiguration:))]
583        #[unsafe(method_family = none)]
584        pub fn imageWithConfiguration(
585            &self,
586            configuration: &UIImageConfiguration,
587        ) -> Retained<UIImage>;
588
589        #[cfg(all(
590            feature = "UIImageConfiguration",
591            feature = "UIImageSymbolConfiguration"
592        ))]
593        /// This property is not atomic.
594        ///
595        /// # Safety
596        ///
597        /// This might not be thread-safe.
598        #[unsafe(method(symbolConfiguration))]
599        #[unsafe(method_family = none)]
600        pub unsafe fn symbolConfiguration(&self) -> Option<Retained<UIImageSymbolConfiguration>>;
601
602        #[cfg(all(
603            feature = "UIImageConfiguration",
604            feature = "UIImageSymbolConfiguration"
605        ))]
606        #[unsafe(method(imageByApplyingSymbolConfiguration:))]
607        #[unsafe(method_family = none)]
608        pub fn imageByApplyingSymbolConfiguration(
609            &self,
610            configuration: &UIImageSymbolConfiguration,
611        ) -> Option<Retained<UIImage>>;
612
613        #[cfg(feature = "UIColor")]
614        #[unsafe(method(imageWithTintColor:))]
615        #[unsafe(method_family = none)]
616        pub fn imageWithTintColor(&self, color: &UIColor) -> Retained<UIImage>;
617
618        #[cfg(feature = "UIColor")]
619        #[unsafe(method(imageWithTintColor:renderingMode:))]
620        #[unsafe(method_family = none)]
621        pub fn imageWithTintColor_renderingMode(
622            &self,
623            color: &UIColor,
624            rendering_mode: UIImageRenderingMode,
625        ) -> Retained<UIImage>;
626
627        /// Decodes an image synchronously and provides a new one for display in views and animations.
628        ///
629        ///
630        /// Returns: A new version of the image object for display. If the system can’t decode the image, this method returns `nil`.
631        ///
632        ///
633        /// Note: The prepared `UIImage` is not related to the original image. If the properties of the screen (such as its resolution or color gamut) change, or if the image is displayed on a different screen that the one it was prepared for, it may not render correctly.
634        #[unsafe(method(imageByPreparingForDisplay))]
635        #[unsafe(method_family = none)]
636        pub fn imageByPreparingForDisplay(&self) -> Option<Retained<UIImage>>;
637
638        #[cfg(feature = "block2")]
639        /// Decodes an image asynchronously and provides a new one for display in views and animations.
640        ///
641        /// The completion handler will be invoked on a private queue. Be sure to return to the main queue before assigning the prepared image to an image view.
642        ///
643        ///
644        /// Parameter `completionHandler`: A block to invoke with the prepared image. If preparation failed (for example, because the image data is corrupt),
645        /// `image`will be `nil`.
646        ///
647        ///
648        /// Note: The prepared `UIImage` is not related to the original image. If the properties of the screen (such as its resolution or color gamut) change, or if the image is displayed on a different screen that the one it was prepared for, it may not render correctly.
649        #[unsafe(method(prepareForDisplayWithCompletionHandler:))]
650        #[unsafe(method_family = none)]
651        pub fn prepareForDisplayWithCompletionHandler(
652            &self,
653            completion_handler: &block2::DynBlock<dyn Fn(*mut UIImage)>,
654        );
655
656        #[cfg(feature = "objc2-core-foundation")]
657        #[unsafe(method(imageByPreparingThumbnailOfSize:))]
658        #[unsafe(method_family = none)]
659        pub fn imageByPreparingThumbnailOfSize(&self, size: CGSize) -> Option<Retained<UIImage>>;
660
661        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
662        #[unsafe(method(prepareThumbnailOfSize:completionHandler:))]
663        #[unsafe(method_family = none)]
664        pub fn prepareThumbnailOfSize_completionHandler(
665            &self,
666            size: CGSize,
667            completion_handler: &block2::DynBlock<dyn Fn(*mut UIImage)>,
668        );
669
670        /// Indicates that this image is tagged for display of high dynamic range content.
671        ///
672        /// This property is not atomic.
673        ///
674        /// # Safety
675        ///
676        /// This might not be thread-safe.
677        #[unsafe(method(isHighDynamicRange))]
678        #[unsafe(method_family = none)]
679        pub unsafe fn isHighDynamicRange(&self) -> bool;
680
681        /// Returns a new image that will render within the standard range.
682        #[unsafe(method(imageRestrictedToStandardDynamicRange))]
683        #[unsafe(method_family = none)]
684        pub fn imageRestrictedToStandardDynamicRange(&self) -> Retained<UIImage>;
685    );
686}
687
688/// Methods declared on superclass `NSObject`.
689impl UIImage {
690    extern_methods!(
691        #[unsafe(method(init))]
692        #[unsafe(method_family = init)]
693        pub fn init(this: Allocated<Self>) -> Retained<Self>;
694
695        #[unsafe(method(new))]
696        #[unsafe(method_family = new)]
697        pub fn new() -> Retained<Self>;
698    );
699}
700
701impl DefaultRetained for UIImage {
702    #[inline]
703    fn default_retained() -> Retained<Self> {
704        Self::new()
705    }
706}
707
708/// PreconfiguredSystemImages.
709impl UIImage {
710    extern_methods!(
711        #[unsafe(method(actionsImage))]
712        #[unsafe(method_family = none)]
713        pub fn actionsImage() -> Retained<UIImage>;
714
715        #[unsafe(method(addImage))]
716        #[unsafe(method_family = none)]
717        pub fn addImage() -> Retained<UIImage>;
718
719        #[unsafe(method(removeImage))]
720        #[unsafe(method_family = none)]
721        pub fn removeImage() -> Retained<UIImage>;
722
723        #[unsafe(method(checkmarkImage))]
724        #[unsafe(method_family = none)]
725        pub fn checkmarkImage() -> Retained<UIImage>;
726
727        #[unsafe(method(strokedCheckmarkImage))]
728        #[unsafe(method_family = none)]
729        pub fn strokedCheckmarkImage() -> Retained<UIImage>;
730    );
731}
732
733/// NSItemProvider.
734impl UIImage {
735    extern_methods!();
736}
737
738extern_conformance!(
739    unsafe impl NSItemProviderReading for UIImage {}
740);
741
742extern_conformance!(
743    unsafe impl NSItemProviderWriting for UIImage {}
744);
745
746/// UIImage.
747#[cfg(feature = "NSTextAttachment")]
748impl NSTextAttachment {
749    extern_methods!(
750        #[unsafe(method(textAttachmentWithImage:))]
751        #[unsafe(method_family = none)]
752        pub fn textAttachmentWithImage(image: &UIImage) -> Retained<NSTextAttachment>;
753    );
754}
755
756/// UIImageDeprecated.
757impl UIImage {
758    extern_methods!(
759        #[unsafe(method(stretchableImageWithLeftCapWidth:topCapHeight:))]
760        #[unsafe(method_family = none)]
761        pub fn stretchableImageWithLeftCapWidth_topCapHeight(
762            &self,
763            left_cap_width: NSInteger,
764            top_cap_height: NSInteger,
765        ) -> Retained<UIImage>;
766
767        /// This property is not atomic.
768        ///
769        /// # Safety
770        ///
771        /// This might not be thread-safe.
772        #[unsafe(method(leftCapWidth))]
773        #[unsafe(method_family = none)]
774        pub unsafe fn leftCapWidth(&self) -> NSInteger;
775
776        /// This property is not atomic.
777        ///
778        /// # Safety
779        ///
780        /// This might not be thread-safe.
781        #[unsafe(method(topCapHeight))]
782        #[unsafe(method_family = none)]
783        pub unsafe fn topCapHeight(&self) -> NSInteger;
784    );
785}
786
787mod private_CIImageUIKitAdditions {
788    pub trait Sealed {}
789}
790
791/// Category "UIKitAdditions" on [`CIImage`].
792#[doc(alias = "UIKitAdditions")]
793pub unsafe trait CIImageUIKitAdditions:
794    ClassType + Sized + private_CIImageUIKitAdditions::Sealed
795{
796    extern_methods!(
797        #[unsafe(method(initWithImage:))]
798        #[unsafe(method_family = init)]
799        fn initWithImage(this: Allocated<Self>, image: &UIImage) -> Option<Retained<Self>>;
800
801        #[cfg(feature = "objc2-core-image")]
802        #[cfg(not(target_os = "watchos"))]
803        /// # Safety
804        ///
805        /// `options` generic should be of the correct type.
806        #[unsafe(method(initWithImage:options:))]
807        #[unsafe(method_family = init)]
808        unsafe fn initWithImage_options(
809            this: Allocated<Self>,
810            image: &UIImage,
811            options: Option<&NSDictionary<CIImageOption, AnyObject>>,
812        ) -> Option<Retained<Self>>;
813    );
814}
815
816#[cfg(feature = "objc2-core-image")]
817#[cfg(not(target_os = "watchos"))]
818impl private_CIImageUIKitAdditions::Sealed for CIImage {}
819#[cfg(feature = "objc2-core-image")]
820#[cfg(not(target_os = "watchos"))]
821unsafe impl CIImageUIKitAdditions for CIImage {}
822
823impl UIImage {
824    /// return image as PNG. May return nil if image has no CGImageRef or invalid bitmap format
825    #[doc(alias = "UIImagePNGRepresentation")]
826    #[inline]
827    pub fn png_representation(&self) -> Option<Retained<NSData>> {
828        extern "C-unwind" {
829            fn UIImagePNGRepresentation(image: &UIImage) -> *mut NSData;
830        }
831        let ret = unsafe { UIImagePNGRepresentation(self) };
832        unsafe { Retained::retain_autoreleased(ret) }
833    }
834
835    /// return image as JPEG. May return nil if image has no CGImageRef or invalid bitmap format. compression is 0(most)..1(least)
836    #[doc(alias = "UIImageJPEGRepresentation")]
837    #[cfg(feature = "objc2-core-foundation")]
838    #[inline]
839    pub fn jpeg_representation(&self, compression_quality: CGFloat) -> Option<Retained<NSData>> {
840        extern "C-unwind" {
841            fn UIImageJPEGRepresentation(
842                image: &UIImage,
843                compression_quality: CGFloat,
844            ) -> *mut NSData;
845        }
846        let ret = unsafe { UIImageJPEGRepresentation(self, compression_quality) };
847        unsafe { Retained::retain_autoreleased(ret) }
848    }
849
850    /// Returns HEIC data representing the image, or nil if such a representation could not be generated. HEIC is recommended for efficiently storing all kinds of images, including those with high dynamic range content.
851    #[doc(alias = "UIImageHEICRepresentation")]
852    #[inline]
853    pub fn heic_representation(&self) -> Option<Retained<NSData>> {
854        extern "C-unwind" {
855            fn UIImageHEICRepresentation(image: &UIImage) -> *mut NSData;
856        }
857        let ret = unsafe { UIImageHEICRepresentation(self) };
858        unsafe { Retained::retain_autoreleased(ret) }
859    }
860}
861
862#[deprecated = "renamed to `UIImage::png_representation`"]
863#[inline]
864pub extern "C-unwind" fn UIImagePNGRepresentation(image: &UIImage) -> Option<Retained<NSData>> {
865    extern "C-unwind" {
866        fn UIImagePNGRepresentation(image: &UIImage) -> *mut NSData;
867    }
868    let ret = unsafe { UIImagePNGRepresentation(image) };
869    unsafe { Retained::retain_autoreleased(ret) }
870}
871
872#[cfg(feature = "objc2-core-foundation")]
873#[deprecated = "renamed to `UIImage::jpeg_representation`"]
874#[inline]
875pub extern "C-unwind" fn UIImageJPEGRepresentation(
876    image: &UIImage,
877    compression_quality: CGFloat,
878) -> Option<Retained<NSData>> {
879    extern "C-unwind" {
880        fn UIImageJPEGRepresentation(image: &UIImage, compression_quality: CGFloat) -> *mut NSData;
881    }
882    let ret = unsafe { UIImageJPEGRepresentation(image, compression_quality) };
883    unsafe { Retained::retain_autoreleased(ret) }
884}
885
886#[deprecated = "renamed to `UIImage::heic_representation`"]
887#[inline]
888pub extern "C-unwind" fn UIImageHEICRepresentation(image: &UIImage) -> Option<Retained<NSData>> {
889    extern "C-unwind" {
890        fn UIImageHEICRepresentation(image: &UIImage) -> *mut NSData;
891    }
892    let ret = unsafe { UIImageHEICRepresentation(image) };
893    unsafe { Retained::retain_autoreleased(ret) }
894}