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 #[doc(alias = "UIImageResizingModeTile")]
56 pub const Tile: Self = Self(0);
57 #[doc(alias = "UIImageResizingModeStretch")]
58 pub const Stretch: Self = Self(1);
59}
60
61unsafe impl Encode for UIImageResizingMode {
62 const ENCODING: Encoding = NSInteger::ENCODING;
63}
64
65unsafe impl RefEncode for UIImageResizingMode {
66 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
67}
68
69#[repr(transparent)]
72#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
73pub struct UIImageRenderingMode(pub NSInteger);
74impl UIImageRenderingMode {
75 #[doc(alias = "UIImageRenderingModeAutomatic")]
76 pub const Automatic: Self = Self(0);
77 #[doc(alias = "UIImageRenderingModeAlwaysOriginal")]
78 pub const AlwaysOriginal: Self = Self(1);
79 #[doc(alias = "UIImageRenderingModeAlwaysTemplate")]
80 pub const AlwaysTemplate: Self = Self(2);
81}
82
83unsafe impl Encode for UIImageRenderingMode {
84 const ENCODING: Encoding = NSInteger::ENCODING;
85}
86
87unsafe impl RefEncode for UIImageRenderingMode {
88 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
89}
90
91extern_class!(
92 #[unsafe(super(NSObject))]
94 #[derive(Debug, PartialEq, Eq, Hash)]
95 pub struct UIImage;
96);
97
98unsafe impl Send for UIImage {}
99
100unsafe impl Sync for UIImage {}
101
102unsafe impl NSCoding for UIImage {}
103
104unsafe impl NSObjectProtocol for UIImage {}
105
106unsafe impl NSSecureCoding for UIImage {}
107
108impl UIImage {
109 extern_methods!(
110 #[unsafe(method(systemImageNamed:))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn systemImageNamed(name: &NSString) -> Option<Retained<UIImage>>;
113
114 #[cfg(feature = "UIImageConfiguration")]
115 #[unsafe(method(systemImageNamed:withConfiguration:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn systemImageNamed_withConfiguration(
118 name: &NSString,
119 configuration: Option<&UIImageConfiguration>,
120 ) -> Option<Retained<UIImage>>;
121
122 #[cfg(feature = "UITraitCollection")]
123 #[unsafe(method(systemImageNamed:compatibleWithTraitCollection:))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn systemImageNamed_compatibleWithTraitCollection(
126 name: &NSString,
127 trait_collection: Option<&UITraitCollection>,
128 ) -> Option<Retained<UIImage>>;
129
130 #[cfg(feature = "UIImageConfiguration")]
131 #[unsafe(method(systemImageNamed:variableValue:withConfiguration:))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn systemImageNamed_variableValue_withConfiguration(
141 name: &NSString,
142 value: c_double,
143 configuration: Option<&UIImageConfiguration>,
144 ) -> Option<Retained<UIImage>>;
145
146 #[unsafe(method(imageNamed:))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn imageNamed(name: &NSString) -> Option<Retained<UIImage>>;
149
150 #[cfg(feature = "UIImageConfiguration")]
151 #[unsafe(method(imageNamed:inBundle:withConfiguration:))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn imageNamed_inBundle_withConfiguration(
154 name: &NSString,
155 bundle: Option<&NSBundle>,
156 configuration: Option<&UIImageConfiguration>,
157 ) -> Option<Retained<UIImage>>;
158
159 #[cfg(feature = "UITraitCollection")]
160 #[unsafe(method(imageNamed:inBundle:compatibleWithTraitCollection:))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn imageNamed_inBundle_compatibleWithTraitCollection(
163 name: &NSString,
164 bundle: Option<&NSBundle>,
165 trait_collection: Option<&UITraitCollection>,
166 ) -> Option<Retained<UIImage>>;
167
168 #[cfg(feature = "UIImageConfiguration")]
169 #[unsafe(method(imageNamed:inBundle:variableValue:withConfiguration:))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn imageNamed_inBundle_variableValue_withConfiguration(
179 name: &NSString,
180 bundle: Option<&NSBundle>,
181 value: c_double,
182 configuration: Option<&UIImageConfiguration>,
183 ) -> Option<Retained<UIImage>>;
184
185 #[unsafe(method(imageWithContentsOfFile:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn imageWithContentsOfFile(path: &NSString) -> Option<Retained<UIImage>>;
188
189 #[unsafe(method(imageWithData:))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn imageWithData(data: &NSData) -> Option<Retained<UIImage>>;
192
193 #[cfg(feature = "objc2-core-foundation")]
194 #[unsafe(method(imageWithData:scale:))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn imageWithData_scale(
197 data: &NSData,
198 scale: CGFloat,
199 ) -> Option<Retained<UIImage>>;
200
201 #[cfg(feature = "objc2-core-graphics")]
202 #[unsafe(method(imageWithCGImage:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn imageWithCGImage(cg_image: &CGImage) -> Retained<UIImage>;
205
206 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
207 #[unsafe(method(imageWithCGImage:scale:orientation:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn imageWithCGImage_scale_orientation(
210 cg_image: &CGImage,
211 scale: CGFloat,
212 orientation: UIImageOrientation,
213 ) -> Retained<UIImage>;
214
215 #[cfg(feature = "objc2-core-image")]
216 #[cfg(not(target_os = "watchos"))]
217 #[unsafe(method(imageWithCIImage:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn imageWithCIImage(ci_image: &CIImage) -> Retained<UIImage>;
220
221 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-image"))]
222 #[cfg(not(target_os = "watchos"))]
223 #[unsafe(method(imageWithCIImage:scale:orientation:))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn imageWithCIImage_scale_orientation(
226 ci_image: &CIImage,
227 scale: CGFloat,
228 orientation: UIImageOrientation,
229 ) -> Retained<UIImage>;
230
231 #[unsafe(method(initWithContentsOfFile:))]
232 #[unsafe(method_family = init)]
233 pub unsafe fn initWithContentsOfFile(
234 this: Allocated<Self>,
235 path: &NSString,
236 ) -> Option<Retained<Self>>;
237
238 #[unsafe(method(initWithData:))]
239 #[unsafe(method_family = init)]
240 pub unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;
241
242 #[cfg(feature = "objc2-core-foundation")]
243 #[unsafe(method(initWithData:scale:))]
244 #[unsafe(method_family = init)]
245 pub unsafe fn initWithData_scale(
246 this: Allocated<Self>,
247 data: &NSData,
248 scale: CGFloat,
249 ) -> Option<Retained<Self>>;
250
251 #[cfg(feature = "objc2-core-graphics")]
252 #[unsafe(method(initWithCGImage:))]
253 #[unsafe(method_family = init)]
254 pub unsafe fn initWithCGImage(this: Allocated<Self>, cg_image: &CGImage) -> Retained<Self>;
255
256 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
257 #[unsafe(method(initWithCGImage:scale:orientation:))]
258 #[unsafe(method_family = init)]
259 pub unsafe fn initWithCGImage_scale_orientation(
260 this: Allocated<Self>,
261 cg_image: &CGImage,
262 scale: CGFloat,
263 orientation: UIImageOrientation,
264 ) -> Retained<Self>;
265
266 #[cfg(feature = "objc2-core-image")]
267 #[cfg(not(target_os = "watchos"))]
268 #[unsafe(method(initWithCIImage:))]
269 #[unsafe(method_family = init)]
270 pub unsafe fn initWithCIImage(this: Allocated<Self>, ci_image: &CIImage) -> Retained<Self>;
271
272 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-image"))]
273 #[cfg(not(target_os = "watchos"))]
274 #[unsafe(method(initWithCIImage:scale:orientation:))]
275 #[unsafe(method_family = init)]
276 pub unsafe fn initWithCIImage_scale_orientation(
277 this: Allocated<Self>,
278 ci_image: &CIImage,
279 scale: CGFloat,
280 orientation: UIImageOrientation,
281 ) -> Retained<Self>;
282
283 #[cfg(feature = "objc2-core-foundation")]
284 #[unsafe(method(size))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn size(&self) -> CGSize;
287
288 #[cfg(feature = "objc2-core-graphics")]
289 #[unsafe(method(CGImage))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn CGImage(&self) -> Option<Retained<CGImage>>;
292
293 #[cfg(feature = "objc2-core-image")]
294 #[cfg(not(target_os = "watchos"))]
295 #[unsafe(method(CIImage))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn CIImage(&self) -> Option<Retained<CIImage>>;
298
299 #[unsafe(method(imageOrientation))]
300 #[unsafe(method_family = none)]
301 pub unsafe fn imageOrientation(&self) -> UIImageOrientation;
302
303 #[cfg(feature = "objc2-core-foundation")]
304 #[unsafe(method(scale))]
305 #[unsafe(method_family = none)]
306 pub unsafe fn scale(&self) -> CGFloat;
307
308 #[unsafe(method(isSymbolImage))]
309 #[unsafe(method_family = none)]
310 pub unsafe fn isSymbolImage(&self) -> bool;
311
312 #[unsafe(method(animatedImageNamed:duration:))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn animatedImageNamed_duration(
315 name: &NSString,
316 duration: NSTimeInterval,
317 ) -> Option<Retained<UIImage>>;
318
319 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
320 #[unsafe(method(animatedResizableImageNamed:capInsets:duration:))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn animatedResizableImageNamed_capInsets_duration(
323 name: &NSString,
324 cap_insets: UIEdgeInsets,
325 duration: NSTimeInterval,
326 ) -> Option<Retained<UIImage>>;
327
328 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
329 #[unsafe(method(animatedResizableImageNamed:capInsets:resizingMode:duration:))]
330 #[unsafe(method_family = none)]
331 pub unsafe fn animatedResizableImageNamed_capInsets_resizingMode_duration(
332 name: &NSString,
333 cap_insets: UIEdgeInsets,
334 resizing_mode: UIImageResizingMode,
335 duration: NSTimeInterval,
336 ) -> Option<Retained<UIImage>>;
337
338 #[unsafe(method(animatedImageWithImages:duration:))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn animatedImageWithImages_duration(
341 images: &NSArray<UIImage>,
342 duration: NSTimeInterval,
343 ) -> Option<Retained<UIImage>>;
344
345 #[unsafe(method(images))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn images(&self) -> Option<Retained<NSArray<UIImage>>>;
348
349 #[unsafe(method(duration))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn duration(&self) -> NSTimeInterval;
352
353 #[cfg(feature = "objc2-core-foundation")]
354 #[unsafe(method(drawAtPoint:))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn drawAtPoint(&self, point: CGPoint);
357
358 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
359 #[unsafe(method(drawAtPoint:blendMode:alpha:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn drawAtPoint_blendMode_alpha(
362 &self,
363 point: CGPoint,
364 blend_mode: CGBlendMode,
365 alpha: CGFloat,
366 );
367
368 #[cfg(feature = "objc2-core-foundation")]
369 #[unsafe(method(drawInRect:))]
370 #[unsafe(method_family = none)]
371 pub unsafe fn drawInRect(&self, rect: CGRect);
372
373 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
374 #[unsafe(method(drawInRect:blendMode:alpha:))]
375 #[unsafe(method_family = none)]
376 pub unsafe fn drawInRect_blendMode_alpha(
377 &self,
378 rect: CGRect,
379 blend_mode: CGBlendMode,
380 alpha: CGFloat,
381 );
382
383 #[cfg(feature = "objc2-core-foundation")]
384 #[unsafe(method(drawAsPatternInRect:))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn drawAsPatternInRect(&self, rect: CGRect);
387
388 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
389 #[unsafe(method(resizableImageWithCapInsets:))]
390 #[unsafe(method_family = none)]
391 pub unsafe fn resizableImageWithCapInsets(
392 &self,
393 cap_insets: UIEdgeInsets,
394 ) -> Retained<UIImage>;
395
396 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
397 #[unsafe(method(resizableImageWithCapInsets:resizingMode:))]
398 #[unsafe(method_family = none)]
399 pub unsafe fn resizableImageWithCapInsets_resizingMode(
400 &self,
401 cap_insets: UIEdgeInsets,
402 resizing_mode: UIImageResizingMode,
403 ) -> Retained<UIImage>;
404
405 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
406 #[unsafe(method(capInsets))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn capInsets(&self) -> UIEdgeInsets;
409
410 #[unsafe(method(resizingMode))]
411 #[unsafe(method_family = none)]
412 pub unsafe fn resizingMode(&self) -> UIImageResizingMode;
413
414 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
415 #[unsafe(method(imageWithAlignmentRectInsets:))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn imageWithAlignmentRectInsets(
418 &self,
419 alignment_insets: UIEdgeInsets,
420 ) -> Retained<UIImage>;
421
422 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
423 #[unsafe(method(alignmentRectInsets))]
424 #[unsafe(method_family = none)]
425 pub unsafe fn alignmentRectInsets(&self) -> UIEdgeInsets;
426
427 #[unsafe(method(imageWithRenderingMode:))]
428 #[unsafe(method_family = none)]
429 pub unsafe fn imageWithRenderingMode(
430 &self,
431 rendering_mode: UIImageRenderingMode,
432 ) -> Retained<UIImage>;
433
434 #[unsafe(method(renderingMode))]
435 #[unsafe(method_family = none)]
436 pub unsafe fn renderingMode(&self) -> UIImageRenderingMode;
437
438 #[cfg(all(feature = "UIGraphicsImageRenderer", feature = "UIGraphicsRenderer"))]
439 #[unsafe(method(imageRendererFormat))]
440 #[unsafe(method_family = none)]
441 pub unsafe fn imageRendererFormat(&self) -> Retained<UIGraphicsImageRendererFormat>;
442
443 #[cfg(feature = "UITraitCollection")]
444 #[unsafe(method(traitCollection))]
445 #[unsafe(method_family = none)]
446 pub unsafe fn traitCollection(&self) -> Retained<UITraitCollection>;
447
448 #[cfg(feature = "UIImageAsset")]
449 #[unsafe(method(imageAsset))]
450 #[unsafe(method_family = none)]
451 pub unsafe fn imageAsset(&self) -> Option<Retained<UIImageAsset>>;
452
453 #[unsafe(method(imageFlippedForRightToLeftLayoutDirection))]
454 #[unsafe(method_family = none)]
455 pub unsafe fn imageFlippedForRightToLeftLayoutDirection(&self) -> Retained<UIImage>;
456
457 #[unsafe(method(flipsForRightToLeftLayoutDirection))]
458 #[unsafe(method_family = none)]
459 pub unsafe fn flipsForRightToLeftLayoutDirection(&self) -> bool;
460
461 #[unsafe(method(imageWithHorizontallyFlippedOrientation))]
462 #[unsafe(method_family = none)]
463 pub unsafe fn imageWithHorizontallyFlippedOrientation(&self) -> Retained<UIImage>;
464
465 #[cfg(feature = "objc2-core-foundation")]
466 #[unsafe(method(baselineOffsetFromBottom))]
467 #[unsafe(method_family = none)]
468 pub unsafe fn baselineOffsetFromBottom(&self) -> CGFloat;
469
470 #[unsafe(method(hasBaseline))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn hasBaseline(&self) -> bool;
473
474 #[cfg(feature = "objc2-core-foundation")]
475 #[unsafe(method(imageWithBaselineOffsetFromBottom:))]
476 #[unsafe(method_family = none)]
477 pub unsafe fn imageWithBaselineOffsetFromBottom(
478 &self,
479 baseline_offset: CGFloat,
480 ) -> Retained<UIImage>;
481
482 #[unsafe(method(imageWithoutBaseline))]
483 #[unsafe(method_family = none)]
484 pub unsafe fn imageWithoutBaseline(&self) -> Retained<UIImage>;
485
486 #[cfg(feature = "UIImageConfiguration")]
487 #[unsafe(method(configuration))]
488 #[unsafe(method_family = none)]
489 pub unsafe fn configuration(&self) -> Option<Retained<UIImageConfiguration>>;
490
491 #[cfg(feature = "UIImageConfiguration")]
492 #[unsafe(method(imageWithConfiguration:))]
493 #[unsafe(method_family = none)]
494 pub unsafe fn imageWithConfiguration(
495 &self,
496 configuration: &UIImageConfiguration,
497 ) -> Retained<UIImage>;
498
499 #[cfg(all(
500 feature = "UIImageConfiguration",
501 feature = "UIImageSymbolConfiguration"
502 ))]
503 #[unsafe(method(symbolConfiguration))]
504 #[unsafe(method_family = none)]
505 pub unsafe fn symbolConfiguration(&self) -> Option<Retained<UIImageSymbolConfiguration>>;
506
507 #[cfg(all(
508 feature = "UIImageConfiguration",
509 feature = "UIImageSymbolConfiguration"
510 ))]
511 #[unsafe(method(imageByApplyingSymbolConfiguration:))]
512 #[unsafe(method_family = none)]
513 pub unsafe fn imageByApplyingSymbolConfiguration(
514 &self,
515 configuration: &UIImageSymbolConfiguration,
516 ) -> Option<Retained<UIImage>>;
517
518 #[cfg(feature = "UIColor")]
519 #[unsafe(method(imageWithTintColor:))]
520 #[unsafe(method_family = none)]
521 pub unsafe fn imageWithTintColor(&self, color: &UIColor) -> Retained<UIImage>;
522
523 #[cfg(feature = "UIColor")]
524 #[unsafe(method(imageWithTintColor:renderingMode:))]
525 #[unsafe(method_family = none)]
526 pub unsafe fn imageWithTintColor_renderingMode(
527 &self,
528 color: &UIColor,
529 rendering_mode: UIImageRenderingMode,
530 ) -> Retained<UIImage>;
531
532 #[unsafe(method(imageByPreparingForDisplay))]
540 #[unsafe(method_family = none)]
541 pub unsafe fn imageByPreparingForDisplay(&self) -> Option<Retained<UIImage>>;
542
543 #[cfg(feature = "block2")]
544 #[unsafe(method(prepareForDisplayWithCompletionHandler:))]
555 #[unsafe(method_family = none)]
556 pub unsafe fn prepareForDisplayWithCompletionHandler(
557 &self,
558 completion_handler: &block2::Block<dyn Fn(*mut UIImage)>,
559 );
560
561 #[cfg(feature = "objc2-core-foundation")]
562 #[unsafe(method(imageByPreparingThumbnailOfSize:))]
563 #[unsafe(method_family = none)]
564 pub unsafe fn imageByPreparingThumbnailOfSize(
565 &self,
566 size: CGSize,
567 ) -> Option<Retained<UIImage>>;
568
569 #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
570 #[unsafe(method(prepareThumbnailOfSize:completionHandler:))]
571 #[unsafe(method_family = none)]
572 pub unsafe fn prepareThumbnailOfSize_completionHandler(
573 &self,
574 size: CGSize,
575 completion_handler: &block2::Block<dyn Fn(*mut UIImage)>,
576 );
577
578 #[unsafe(method(isHighDynamicRange))]
580 #[unsafe(method_family = none)]
581 pub unsafe fn isHighDynamicRange(&self) -> bool;
582
583 #[unsafe(method(imageRestrictedToStandardDynamicRange))]
585 #[unsafe(method_family = none)]
586 pub unsafe fn imageRestrictedToStandardDynamicRange(&self) -> Retained<UIImage>;
587 );
588}
589
590impl UIImage {
592 extern_methods!(
593 #[unsafe(method(init))]
594 #[unsafe(method_family = init)]
595 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
596
597 #[unsafe(method(new))]
598 #[unsafe(method_family = new)]
599 pub unsafe fn new() -> Retained<Self>;
600 );
601}
602
603impl UIImage {
605 extern_methods!(
606 #[unsafe(method(actionsImage))]
607 #[unsafe(method_family = none)]
608 pub unsafe fn actionsImage() -> Retained<UIImage>;
609
610 #[unsafe(method(addImage))]
611 #[unsafe(method_family = none)]
612 pub unsafe fn addImage() -> Retained<UIImage>;
613
614 #[unsafe(method(removeImage))]
615 #[unsafe(method_family = none)]
616 pub unsafe fn removeImage() -> Retained<UIImage>;
617
618 #[unsafe(method(checkmarkImage))]
619 #[unsafe(method_family = none)]
620 pub unsafe fn checkmarkImage() -> Retained<UIImage>;
621
622 #[unsafe(method(strokedCheckmarkImage))]
623 #[unsafe(method_family = none)]
624 pub unsafe fn strokedCheckmarkImage() -> Retained<UIImage>;
625 );
626}
627
628impl UIImage {
630 extern_methods!();
631}
632
633unsafe impl NSItemProviderReading for UIImage {}
634
635unsafe impl NSItemProviderWriting for UIImage {}
636
637#[cfg(feature = "NSTextAttachment")]
639impl NSTextAttachment {
640 extern_methods!(
641 #[unsafe(method(textAttachmentWithImage:))]
642 #[unsafe(method_family = none)]
643 pub unsafe fn textAttachmentWithImage(image: &UIImage) -> Retained<NSTextAttachment>;
644 );
645}
646
647impl UIImage {
649 extern_methods!(
650 #[unsafe(method(stretchableImageWithLeftCapWidth:topCapHeight:))]
651 #[unsafe(method_family = none)]
652 pub unsafe fn stretchableImageWithLeftCapWidth_topCapHeight(
653 &self,
654 left_cap_width: NSInteger,
655 top_cap_height: NSInteger,
656 ) -> Retained<UIImage>;
657
658 #[unsafe(method(leftCapWidth))]
659 #[unsafe(method_family = none)]
660 pub unsafe fn leftCapWidth(&self) -> NSInteger;
661
662 #[unsafe(method(topCapHeight))]
663 #[unsafe(method_family = none)]
664 pub unsafe fn topCapHeight(&self) -> NSInteger;
665 );
666}
667
668mod private_CIImageUIKitAdditions {
669 pub trait Sealed {}
670}
671
672#[doc(alias = "UIKitAdditions")]
674pub unsafe trait CIImageUIKitAdditions:
675 ClassType + Sized + private_CIImageUIKitAdditions::Sealed
676{
677 extern_methods!(
678 #[unsafe(method(initWithImage:))]
679 #[unsafe(method_family = init)]
680 unsafe fn initWithImage(this: Allocated<Self>, image: &UIImage) -> Option<Retained<Self>>;
681
682 #[cfg(feature = "objc2-core-image")]
683 #[cfg(not(target_os = "watchos"))]
684 #[unsafe(method(initWithImage:options:))]
685 #[unsafe(method_family = init)]
686 unsafe fn initWithImage_options(
687 this: Allocated<Self>,
688 image: &UIImage,
689 options: Option<&NSDictionary<CIImageOption, AnyObject>>,
690 ) -> Option<Retained<Self>>;
691 );
692}
693
694#[cfg(feature = "objc2-core-image")]
695#[cfg(not(target_os = "watchos"))]
696impl private_CIImageUIKitAdditions::Sealed for CIImage {}
697#[cfg(feature = "objc2-core-image")]
698#[cfg(not(target_os = "watchos"))]
699unsafe impl CIImageUIKitAdditions for CIImage {}
700
701#[inline]
703pub unsafe extern "C-unwind" fn UIImagePNGRepresentation(
704 image: &UIImage,
705) -> Option<Retained<NSData>> {
706 extern "C-unwind" {
707 fn UIImagePNGRepresentation(image: &UIImage) -> *mut NSData;
708 }
709 let ret = unsafe { UIImagePNGRepresentation(image) };
710 unsafe { Retained::retain_autoreleased(ret) }
711}
712
713#[cfg(feature = "objc2-core-foundation")]
715#[inline]
716pub unsafe extern "C-unwind" fn UIImageJPEGRepresentation(
717 image: &UIImage,
718 compression_quality: CGFloat,
719) -> Option<Retained<NSData>> {
720 extern "C-unwind" {
721 fn UIImageJPEGRepresentation(image: &UIImage, compression_quality: CGFloat) -> *mut NSData;
722 }
723 let ret = unsafe { UIImageJPEGRepresentation(image, compression_quality) };
724 unsafe { Retained::retain_autoreleased(ret) }
725}
726
727#[inline]
729pub unsafe extern "C-unwind" fn UIImageHEICRepresentation(
730 image: &UIImage,
731) -> Option<Retained<NSData>> {
732 extern "C-unwind" {
733 fn UIImageHEICRepresentation(image: &UIImage) -> *mut NSData;
734 }
735 let ret = unsafe { UIImageHEICRepresentation(image) };
736 unsafe { Retained::retain_autoreleased(ret) }
737}