1use 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#[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#[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#[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 #[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 #[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 #[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 #[unsafe(method(size))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn size(&self) -> CGSize;
290
291 #[cfg(feature = "objc2-core-graphics")]
292 #[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 #[unsafe(method(CIImage))]
309 #[unsafe(method_family = none)]
310 pub unsafe fn CIImage(&self) -> Option<Retained<CIImage>>;
311
312 #[unsafe(method(imageOrientation))]
318 #[unsafe(method_family = none)]
319 pub unsafe fn imageOrientation(&self) -> UIImageOrientation;
320
321 #[cfg(feature = "objc2-core-foundation")]
322 #[unsafe(method(scale))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn scale(&self) -> CGFloat;
330
331 #[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 #[unsafe(method(images))]
379 #[unsafe(method_family = none)]
380 pub unsafe fn images(&self) -> Option<Retained<NSArray<UIImage>>>;
381
382 #[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 #[unsafe(method(capInsets))]
447 #[unsafe(method_family = none)]
448 pub unsafe fn capInsets(&self) -> UIEdgeInsets;
449
450 #[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 #[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 #[unsafe(method(renderingMode))]
490 #[unsafe(method_family = none)]
491 pub unsafe fn renderingMode(&self) -> UIImageRenderingMode;
492
493 #[cfg(all(feature = "UIGraphicsImageRenderer", feature = "UIGraphicsRenderer"))]
494 #[unsafe(method(imageRendererFormat))]
500 #[unsafe(method_family = none)]
501 pub unsafe fn imageRendererFormat(&self) -> Retained<UIGraphicsImageRendererFormat>;
502
503 #[cfg(feature = "UITraitCollection")]
504 #[unsafe(method(traitCollection))]
510 #[unsafe(method_family = none)]
511 pub unsafe fn traitCollection(&self) -> Retained<UITraitCollection>;
512
513 #[cfg(feature = "UIImageAsset")]
514 #[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 #[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 #[unsafe(method(baselineOffsetFromBottom))]
547 #[unsafe(method_family = none)]
548 pub unsafe fn baselineOffsetFromBottom(&self) -> CGFloat;
549
550 #[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 #[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 #[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 #[unsafe(method(imageByPreparingForDisplay))]
635 #[unsafe(method_family = none)]
636 pub fn imageByPreparingForDisplay(&self) -> Option<Retained<UIImage>>;
637
638 #[cfg(feature = "block2")]
639 #[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 #[unsafe(method(isHighDynamicRange))]
678 #[unsafe(method_family = none)]
679 pub unsafe fn isHighDynamicRange(&self) -> bool;
680
681 #[unsafe(method(imageRestrictedToStandardDynamicRange))]
683 #[unsafe(method_family = none)]
684 pub fn imageRestrictedToStandardDynamicRange(&self) -> Retained<UIImage>;
685 );
686}
687
688impl 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
708impl 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
733impl 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#[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
756impl 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 #[unsafe(method(leftCapWidth))]
773 #[unsafe(method_family = none)]
774 pub unsafe fn leftCapWidth(&self) -> NSInteger;
775
776 #[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#[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 #[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 #[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 #[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 #[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}