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
102extern_conformance!(
103 unsafe impl NSCoding for UIImage {}
104);
105
106extern_conformance!(
107 unsafe impl NSObjectProtocol for UIImage {}
108);
109
110extern_conformance!(
111 unsafe impl NSSecureCoding for UIImage {}
112);
113
114impl UIImage {
115 extern_methods!(
116 #[unsafe(method(systemImageNamed:))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn systemImageNamed(name: &NSString) -> Option<Retained<UIImage>>;
119
120 #[cfg(feature = "UIImageConfiguration")]
121 #[unsafe(method(systemImageNamed:withConfiguration:))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn systemImageNamed_withConfiguration(
124 name: &NSString,
125 configuration: Option<&UIImageConfiguration>,
126 ) -> Option<Retained<UIImage>>;
127
128 #[cfg(feature = "UITraitCollection")]
129 #[unsafe(method(systemImageNamed:compatibleWithTraitCollection:))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn systemImageNamed_compatibleWithTraitCollection(
132 name: &NSString,
133 trait_collection: Option<&UITraitCollection>,
134 ) -> Option<Retained<UIImage>>;
135
136 #[cfg(feature = "UIImageConfiguration")]
137 #[unsafe(method(systemImageNamed:variableValue:withConfiguration:))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn systemImageNamed_variableValue_withConfiguration(
147 name: &NSString,
148 value: c_double,
149 configuration: Option<&UIImageConfiguration>,
150 ) -> Option<Retained<UIImage>>;
151
152 #[unsafe(method(imageNamed:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn imageNamed(name: &NSString) -> Option<Retained<UIImage>>;
155
156 #[cfg(feature = "UIImageConfiguration")]
157 #[unsafe(method(imageNamed:inBundle:withConfiguration:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn imageNamed_inBundle_withConfiguration(
160 name: &NSString,
161 bundle: Option<&NSBundle>,
162 configuration: Option<&UIImageConfiguration>,
163 ) -> Option<Retained<UIImage>>;
164
165 #[cfg(feature = "UITraitCollection")]
166 #[unsafe(method(imageNamed:inBundle:compatibleWithTraitCollection:))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn imageNamed_inBundle_compatibleWithTraitCollection(
169 name: &NSString,
170 bundle: Option<&NSBundle>,
171 trait_collection: Option<&UITraitCollection>,
172 ) -> Option<Retained<UIImage>>;
173
174 #[cfg(feature = "UIImageConfiguration")]
175 #[unsafe(method(imageNamed:inBundle:variableValue:withConfiguration:))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn imageNamed_inBundle_variableValue_withConfiguration(
185 name: &NSString,
186 bundle: Option<&NSBundle>,
187 value: c_double,
188 configuration: Option<&UIImageConfiguration>,
189 ) -> Option<Retained<UIImage>>;
190
191 #[unsafe(method(imageWithContentsOfFile:))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn imageWithContentsOfFile(path: &NSString) -> Option<Retained<UIImage>>;
194
195 #[unsafe(method(imageWithData:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn imageWithData(data: &NSData) -> Option<Retained<UIImage>>;
198
199 #[cfg(feature = "objc2-core-foundation")]
200 #[unsafe(method(imageWithData:scale:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn imageWithData_scale(
203 data: &NSData,
204 scale: CGFloat,
205 ) -> Option<Retained<UIImage>>;
206
207 #[cfg(feature = "objc2-core-graphics")]
208 #[unsafe(method(imageWithCGImage:))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn imageWithCGImage(cg_image: &CGImage) -> Retained<UIImage>;
211
212 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
213 #[unsafe(method(imageWithCGImage:scale:orientation:))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn imageWithCGImage_scale_orientation(
216 cg_image: &CGImage,
217 scale: CGFloat,
218 orientation: UIImageOrientation,
219 ) -> Retained<UIImage>;
220
221 #[cfg(feature = "objc2-core-image")]
222 #[cfg(not(target_os = "watchos"))]
223 #[unsafe(method(imageWithCIImage:))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn imageWithCIImage(ci_image: &CIImage) -> Retained<UIImage>;
226
227 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-image"))]
228 #[cfg(not(target_os = "watchos"))]
229 #[unsafe(method(imageWithCIImage:scale:orientation:))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn imageWithCIImage_scale_orientation(
232 ci_image: &CIImage,
233 scale: CGFloat,
234 orientation: UIImageOrientation,
235 ) -> Retained<UIImage>;
236
237 #[unsafe(method(initWithContentsOfFile:))]
238 #[unsafe(method_family = init)]
239 pub unsafe fn initWithContentsOfFile(
240 this: Allocated<Self>,
241 path: &NSString,
242 ) -> Option<Retained<Self>>;
243
244 #[unsafe(method(initWithData:))]
245 #[unsafe(method_family = init)]
246 pub unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;
247
248 #[cfg(feature = "objc2-core-foundation")]
249 #[unsafe(method(initWithData:scale:))]
250 #[unsafe(method_family = init)]
251 pub unsafe fn initWithData_scale(
252 this: Allocated<Self>,
253 data: &NSData,
254 scale: CGFloat,
255 ) -> Option<Retained<Self>>;
256
257 #[cfg(feature = "objc2-core-graphics")]
258 #[unsafe(method(initWithCGImage:))]
259 #[unsafe(method_family = init)]
260 pub unsafe fn initWithCGImage(this: Allocated<Self>, cg_image: &CGImage) -> Retained<Self>;
261
262 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
263 #[unsafe(method(initWithCGImage:scale:orientation:))]
264 #[unsafe(method_family = init)]
265 pub unsafe fn initWithCGImage_scale_orientation(
266 this: Allocated<Self>,
267 cg_image: &CGImage,
268 scale: CGFloat,
269 orientation: UIImageOrientation,
270 ) -> Retained<Self>;
271
272 #[cfg(feature = "objc2-core-image")]
273 #[cfg(not(target_os = "watchos"))]
274 #[unsafe(method(initWithCIImage:))]
275 #[unsafe(method_family = init)]
276 pub unsafe fn initWithCIImage(this: Allocated<Self>, ci_image: &CIImage) -> Retained<Self>;
277
278 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-image"))]
279 #[cfg(not(target_os = "watchos"))]
280 #[unsafe(method(initWithCIImage:scale:orientation:))]
281 #[unsafe(method_family = init)]
282 pub unsafe fn initWithCIImage_scale_orientation(
283 this: Allocated<Self>,
284 ci_image: &CIImage,
285 scale: CGFloat,
286 orientation: UIImageOrientation,
287 ) -> Retained<Self>;
288
289 #[cfg(feature = "objc2-core-foundation")]
290 #[unsafe(method(size))]
291 #[unsafe(method_family = none)]
292 pub unsafe fn size(&self) -> CGSize;
293
294 #[cfg(feature = "objc2-core-graphics")]
295 #[unsafe(method(CGImage))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn CGImage(&self) -> Option<Retained<CGImage>>;
298
299 #[cfg(feature = "objc2-core-image")]
300 #[cfg(not(target_os = "watchos"))]
301 #[unsafe(method(CIImage))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn CIImage(&self) -> Option<Retained<CIImage>>;
304
305 #[unsafe(method(imageOrientation))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn imageOrientation(&self) -> UIImageOrientation;
308
309 #[cfg(feature = "objc2-core-foundation")]
310 #[unsafe(method(scale))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn scale(&self) -> CGFloat;
313
314 #[unsafe(method(isSymbolImage))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn isSymbolImage(&self) -> bool;
317
318 #[unsafe(method(animatedImageNamed:duration:))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn animatedImageNamed_duration(
321 name: &NSString,
322 duration: NSTimeInterval,
323 ) -> Option<Retained<UIImage>>;
324
325 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
326 #[unsafe(method(animatedResizableImageNamed:capInsets:duration:))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn animatedResizableImageNamed_capInsets_duration(
329 name: &NSString,
330 cap_insets: UIEdgeInsets,
331 duration: NSTimeInterval,
332 ) -> Option<Retained<UIImage>>;
333
334 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
335 #[unsafe(method(animatedResizableImageNamed:capInsets:resizingMode:duration:))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn animatedResizableImageNamed_capInsets_resizingMode_duration(
338 name: &NSString,
339 cap_insets: UIEdgeInsets,
340 resizing_mode: UIImageResizingMode,
341 duration: NSTimeInterval,
342 ) -> Option<Retained<UIImage>>;
343
344 #[unsafe(method(animatedImageWithImages:duration:))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn animatedImageWithImages_duration(
347 images: &NSArray<UIImage>,
348 duration: NSTimeInterval,
349 ) -> Option<Retained<UIImage>>;
350
351 #[unsafe(method(images))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn images(&self) -> Option<Retained<NSArray<UIImage>>>;
354
355 #[unsafe(method(duration))]
356 #[unsafe(method_family = none)]
357 pub unsafe fn duration(&self) -> NSTimeInterval;
358
359 #[cfg(feature = "objc2-core-foundation")]
360 #[unsafe(method(drawAtPoint:))]
361 #[unsafe(method_family = none)]
362 pub unsafe fn drawAtPoint(&self, point: CGPoint);
363
364 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
365 #[unsafe(method(drawAtPoint:blendMode:alpha:))]
366 #[unsafe(method_family = none)]
367 pub unsafe fn drawAtPoint_blendMode_alpha(
368 &self,
369 point: CGPoint,
370 blend_mode: CGBlendMode,
371 alpha: CGFloat,
372 );
373
374 #[cfg(feature = "objc2-core-foundation")]
375 #[unsafe(method(drawInRect:))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn drawInRect(&self, rect: CGRect);
378
379 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-graphics"))]
380 #[unsafe(method(drawInRect:blendMode:alpha:))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn drawInRect_blendMode_alpha(
383 &self,
384 rect: CGRect,
385 blend_mode: CGBlendMode,
386 alpha: CGFloat,
387 );
388
389 #[cfg(feature = "objc2-core-foundation")]
390 #[unsafe(method(drawAsPatternInRect:))]
391 #[unsafe(method_family = none)]
392 pub unsafe fn drawAsPatternInRect(&self, rect: CGRect);
393
394 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
395 #[unsafe(method(resizableImageWithCapInsets:))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn resizableImageWithCapInsets(
398 &self,
399 cap_insets: UIEdgeInsets,
400 ) -> Retained<UIImage>;
401
402 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
403 #[unsafe(method(resizableImageWithCapInsets:resizingMode:))]
404 #[unsafe(method_family = none)]
405 pub unsafe fn resizableImageWithCapInsets_resizingMode(
406 &self,
407 cap_insets: UIEdgeInsets,
408 resizing_mode: UIImageResizingMode,
409 ) -> Retained<UIImage>;
410
411 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
412 #[unsafe(method(capInsets))]
413 #[unsafe(method_family = none)]
414 pub unsafe fn capInsets(&self) -> UIEdgeInsets;
415
416 #[unsafe(method(resizingMode))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn resizingMode(&self) -> UIImageResizingMode;
419
420 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
421 #[unsafe(method(imageWithAlignmentRectInsets:))]
422 #[unsafe(method_family = none)]
423 pub unsafe fn imageWithAlignmentRectInsets(
424 &self,
425 alignment_insets: UIEdgeInsets,
426 ) -> Retained<UIImage>;
427
428 #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
429 #[unsafe(method(alignmentRectInsets))]
430 #[unsafe(method_family = none)]
431 pub unsafe fn alignmentRectInsets(&self) -> UIEdgeInsets;
432
433 #[unsafe(method(imageWithRenderingMode:))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn imageWithRenderingMode(
436 &self,
437 rendering_mode: UIImageRenderingMode,
438 ) -> Retained<UIImage>;
439
440 #[unsafe(method(renderingMode))]
441 #[unsafe(method_family = none)]
442 pub unsafe fn renderingMode(&self) -> UIImageRenderingMode;
443
444 #[cfg(all(feature = "UIGraphicsImageRenderer", feature = "UIGraphicsRenderer"))]
445 #[unsafe(method(imageRendererFormat))]
446 #[unsafe(method_family = none)]
447 pub unsafe fn imageRendererFormat(&self) -> Retained<UIGraphicsImageRendererFormat>;
448
449 #[cfg(feature = "UITraitCollection")]
450 #[unsafe(method(traitCollection))]
451 #[unsafe(method_family = none)]
452 pub unsafe fn traitCollection(&self) -> Retained<UITraitCollection>;
453
454 #[cfg(feature = "UIImageAsset")]
455 #[unsafe(method(imageAsset))]
456 #[unsafe(method_family = none)]
457 pub unsafe fn imageAsset(&self) -> Option<Retained<UIImageAsset>>;
458
459 #[unsafe(method(imageFlippedForRightToLeftLayoutDirection))]
460 #[unsafe(method_family = none)]
461 pub unsafe fn imageFlippedForRightToLeftLayoutDirection(&self) -> Retained<UIImage>;
462
463 #[unsafe(method(flipsForRightToLeftLayoutDirection))]
464 #[unsafe(method_family = none)]
465 pub unsafe fn flipsForRightToLeftLayoutDirection(&self) -> bool;
466
467 #[unsafe(method(imageWithHorizontallyFlippedOrientation))]
468 #[unsafe(method_family = none)]
469 pub unsafe fn imageWithHorizontallyFlippedOrientation(&self) -> Retained<UIImage>;
470
471 #[cfg(feature = "objc2-core-foundation")]
472 #[unsafe(method(baselineOffsetFromBottom))]
473 #[unsafe(method_family = none)]
474 pub unsafe fn baselineOffsetFromBottom(&self) -> CGFloat;
475
476 #[unsafe(method(hasBaseline))]
477 #[unsafe(method_family = none)]
478 pub unsafe fn hasBaseline(&self) -> bool;
479
480 #[cfg(feature = "objc2-core-foundation")]
481 #[unsafe(method(imageWithBaselineOffsetFromBottom:))]
482 #[unsafe(method_family = none)]
483 pub unsafe fn imageWithBaselineOffsetFromBottom(
484 &self,
485 baseline_offset: CGFloat,
486 ) -> Retained<UIImage>;
487
488 #[unsafe(method(imageWithoutBaseline))]
489 #[unsafe(method_family = none)]
490 pub unsafe fn imageWithoutBaseline(&self) -> Retained<UIImage>;
491
492 #[cfg(feature = "UIImageConfiguration")]
493 #[unsafe(method(configuration))]
494 #[unsafe(method_family = none)]
495 pub unsafe fn configuration(&self) -> Option<Retained<UIImageConfiguration>>;
496
497 #[cfg(feature = "UIImageConfiguration")]
498 #[unsafe(method(imageWithConfiguration:))]
499 #[unsafe(method_family = none)]
500 pub unsafe fn imageWithConfiguration(
501 &self,
502 configuration: &UIImageConfiguration,
503 ) -> Retained<UIImage>;
504
505 #[cfg(all(
506 feature = "UIImageConfiguration",
507 feature = "UIImageSymbolConfiguration"
508 ))]
509 #[unsafe(method(symbolConfiguration))]
510 #[unsafe(method_family = none)]
511 pub unsafe fn symbolConfiguration(&self) -> Option<Retained<UIImageSymbolConfiguration>>;
512
513 #[cfg(all(
514 feature = "UIImageConfiguration",
515 feature = "UIImageSymbolConfiguration"
516 ))]
517 #[unsafe(method(imageByApplyingSymbolConfiguration:))]
518 #[unsafe(method_family = none)]
519 pub unsafe fn imageByApplyingSymbolConfiguration(
520 &self,
521 configuration: &UIImageSymbolConfiguration,
522 ) -> Option<Retained<UIImage>>;
523
524 #[cfg(feature = "UIColor")]
525 #[unsafe(method(imageWithTintColor:))]
526 #[unsafe(method_family = none)]
527 pub unsafe fn imageWithTintColor(&self, color: &UIColor) -> Retained<UIImage>;
528
529 #[cfg(feature = "UIColor")]
530 #[unsafe(method(imageWithTintColor:renderingMode:))]
531 #[unsafe(method_family = none)]
532 pub unsafe fn imageWithTintColor_renderingMode(
533 &self,
534 color: &UIColor,
535 rendering_mode: UIImageRenderingMode,
536 ) -> Retained<UIImage>;
537
538 #[unsafe(method(imageByPreparingForDisplay))]
546 #[unsafe(method_family = none)]
547 pub unsafe fn imageByPreparingForDisplay(&self) -> Option<Retained<UIImage>>;
548
549 #[cfg(feature = "block2")]
550 #[unsafe(method(prepareForDisplayWithCompletionHandler:))]
561 #[unsafe(method_family = none)]
562 pub unsafe fn prepareForDisplayWithCompletionHandler(
563 &self,
564 completion_handler: &block2::DynBlock<dyn Fn(*mut UIImage)>,
565 );
566
567 #[cfg(feature = "objc2-core-foundation")]
568 #[unsafe(method(imageByPreparingThumbnailOfSize:))]
569 #[unsafe(method_family = none)]
570 pub unsafe fn imageByPreparingThumbnailOfSize(
571 &self,
572 size: CGSize,
573 ) -> Option<Retained<UIImage>>;
574
575 #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
576 #[unsafe(method(prepareThumbnailOfSize:completionHandler:))]
577 #[unsafe(method_family = none)]
578 pub unsafe fn prepareThumbnailOfSize_completionHandler(
579 &self,
580 size: CGSize,
581 completion_handler: &block2::DynBlock<dyn Fn(*mut UIImage)>,
582 );
583
584 #[unsafe(method(isHighDynamicRange))]
586 #[unsafe(method_family = none)]
587 pub unsafe fn isHighDynamicRange(&self) -> bool;
588
589 #[unsafe(method(imageRestrictedToStandardDynamicRange))]
591 #[unsafe(method_family = none)]
592 pub unsafe fn imageRestrictedToStandardDynamicRange(&self) -> Retained<UIImage>;
593 );
594}
595
596impl UIImage {
598 extern_methods!(
599 #[unsafe(method(init))]
600 #[unsafe(method_family = init)]
601 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
602
603 #[unsafe(method(new))]
604 #[unsafe(method_family = new)]
605 pub unsafe fn new() -> Retained<Self>;
606 );
607}
608
609impl UIImage {
611 extern_methods!(
612 #[unsafe(method(actionsImage))]
613 #[unsafe(method_family = none)]
614 pub unsafe fn actionsImage() -> Retained<UIImage>;
615
616 #[unsafe(method(addImage))]
617 #[unsafe(method_family = none)]
618 pub unsafe fn addImage() -> Retained<UIImage>;
619
620 #[unsafe(method(removeImage))]
621 #[unsafe(method_family = none)]
622 pub unsafe fn removeImage() -> Retained<UIImage>;
623
624 #[unsafe(method(checkmarkImage))]
625 #[unsafe(method_family = none)]
626 pub unsafe fn checkmarkImage() -> Retained<UIImage>;
627
628 #[unsafe(method(strokedCheckmarkImage))]
629 #[unsafe(method_family = none)]
630 pub unsafe fn strokedCheckmarkImage() -> Retained<UIImage>;
631 );
632}
633
634impl UIImage {
636 extern_methods!();
637}
638
639extern_conformance!(
640 unsafe impl NSItemProviderReading for UIImage {}
641);
642
643extern_conformance!(
644 unsafe impl NSItemProviderWriting for UIImage {}
645);
646
647#[cfg(feature = "NSTextAttachment")]
649impl NSTextAttachment {
650 extern_methods!(
651 #[unsafe(method(textAttachmentWithImage:))]
652 #[unsafe(method_family = none)]
653 pub unsafe fn textAttachmentWithImage(image: &UIImage) -> Retained<NSTextAttachment>;
654 );
655}
656
657impl UIImage {
659 extern_methods!(
660 #[unsafe(method(stretchableImageWithLeftCapWidth:topCapHeight:))]
661 #[unsafe(method_family = none)]
662 pub unsafe fn stretchableImageWithLeftCapWidth_topCapHeight(
663 &self,
664 left_cap_width: NSInteger,
665 top_cap_height: NSInteger,
666 ) -> Retained<UIImage>;
667
668 #[unsafe(method(leftCapWidth))]
669 #[unsafe(method_family = none)]
670 pub unsafe fn leftCapWidth(&self) -> NSInteger;
671
672 #[unsafe(method(topCapHeight))]
673 #[unsafe(method_family = none)]
674 pub unsafe fn topCapHeight(&self) -> NSInteger;
675 );
676}
677
678mod private_CIImageUIKitAdditions {
679 pub trait Sealed {}
680}
681
682#[doc(alias = "UIKitAdditions")]
684pub unsafe trait CIImageUIKitAdditions:
685 ClassType + Sized + private_CIImageUIKitAdditions::Sealed
686{
687 extern_methods!(
688 #[unsafe(method(initWithImage:))]
689 #[unsafe(method_family = init)]
690 unsafe fn initWithImage(this: Allocated<Self>, image: &UIImage) -> Option<Retained<Self>>;
691
692 #[cfg(feature = "objc2-core-image")]
693 #[cfg(not(target_os = "watchos"))]
694 #[unsafe(method(initWithImage:options:))]
695 #[unsafe(method_family = init)]
696 unsafe fn initWithImage_options(
697 this: Allocated<Self>,
698 image: &UIImage,
699 options: Option<&NSDictionary<CIImageOption, AnyObject>>,
700 ) -> Option<Retained<Self>>;
701 );
702}
703
704#[cfg(feature = "objc2-core-image")]
705#[cfg(not(target_os = "watchos"))]
706impl private_CIImageUIKitAdditions::Sealed for CIImage {}
707#[cfg(feature = "objc2-core-image")]
708#[cfg(not(target_os = "watchos"))]
709unsafe impl CIImageUIKitAdditions for CIImage {}
710
711impl UIImage {
712 #[doc(alias = "UIImagePNGRepresentation")]
714 #[inline]
715 pub unsafe fn png_representation(self: &UIImage) -> Option<Retained<NSData>> {
716 extern "C-unwind" {
717 fn UIImagePNGRepresentation(image: &UIImage) -> *mut NSData;
718 }
719 let ret = unsafe { UIImagePNGRepresentation(self) };
720 unsafe { Retained::retain_autoreleased(ret) }
721 }
722
723 #[doc(alias = "UIImageJPEGRepresentation")]
725 #[cfg(feature = "objc2-core-foundation")]
726 #[inline]
727 pub unsafe fn jpeg_representation(
728 self: &UIImage,
729 compression_quality: CGFloat,
730 ) -> Option<Retained<NSData>> {
731 extern "C-unwind" {
732 fn UIImageJPEGRepresentation(
733 image: &UIImage,
734 compression_quality: CGFloat,
735 ) -> *mut NSData;
736 }
737 let ret = unsafe { UIImageJPEGRepresentation(self, compression_quality) };
738 unsafe { Retained::retain_autoreleased(ret) }
739 }
740
741 #[doc(alias = "UIImageHEICRepresentation")]
743 #[inline]
744 pub unsafe fn heic_representation(self: &UIImage) -> Option<Retained<NSData>> {
745 extern "C-unwind" {
746 fn UIImageHEICRepresentation(image: &UIImage) -> *mut NSData;
747 }
748 let ret = unsafe { UIImageHEICRepresentation(self) };
749 unsafe { Retained::retain_autoreleased(ret) }
750 }
751}
752
753#[deprecated = "renamed to `UIImage::png_representation`"]
754#[inline]
755pub unsafe extern "C-unwind" fn UIImagePNGRepresentation(
756 image: &UIImage,
757) -> Option<Retained<NSData>> {
758 extern "C-unwind" {
759 fn UIImagePNGRepresentation(image: &UIImage) -> *mut NSData;
760 }
761 let ret = unsafe { UIImagePNGRepresentation(image) };
762 unsafe { Retained::retain_autoreleased(ret) }
763}
764
765#[cfg(feature = "objc2-core-foundation")]
766#[deprecated = "renamed to `UIImage::jpeg_representation`"]
767#[inline]
768pub unsafe extern "C-unwind" fn UIImageJPEGRepresentation(
769 image: &UIImage,
770 compression_quality: CGFloat,
771) -> Option<Retained<NSData>> {
772 extern "C-unwind" {
773 fn UIImageJPEGRepresentation(image: &UIImage, compression_quality: CGFloat) -> *mut NSData;
774 }
775 let ret = unsafe { UIImageJPEGRepresentation(image, compression_quality) };
776 unsafe { Retained::retain_autoreleased(ret) }
777}
778
779#[deprecated = "renamed to `UIImage::heic_representation`"]
780#[inline]
781pub unsafe extern "C-unwind" fn UIImageHEICRepresentation(
782 image: &UIImage,
783) -> Option<Retained<NSData>> {
784 extern "C-unwind" {
785 fn UIImageHEICRepresentation(image: &UIImage) -> *mut NSData;
786 }
787 let ret = unsafe { UIImageHEICRepresentation(image) };
788 unsafe { Retained::retain_autoreleased(ret) }
789}