1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-image")]
#[cfg(not(target_os = "watchos"))]
use objc2_core_image::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImageOrientation(pub NSInteger);
impl UIImageOrientation {
    #[doc(alias = "UIImageOrientationUp")]
    pub const Up: Self = Self(0);
    #[doc(alias = "UIImageOrientationDown")]
    pub const Down: Self = Self(1);
    #[doc(alias = "UIImageOrientationLeft")]
    pub const Left: Self = Self(2);
    #[doc(alias = "UIImageOrientationRight")]
    pub const Right: Self = Self(3);
    #[doc(alias = "UIImageOrientationUpMirrored")]
    pub const UpMirrored: Self = Self(4);
    #[doc(alias = "UIImageOrientationDownMirrored")]
    pub const DownMirrored: Self = Self(5);
    #[doc(alias = "UIImageOrientationLeftMirrored")]
    pub const LeftMirrored: Self = Self(6);
    #[doc(alias = "UIImageOrientationRightMirrored")]
    pub const RightMirrored: Self = Self(7);
}

unsafe impl Encode for UIImageOrientation {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImageOrientation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImageResizingMode(pub NSInteger);
impl UIImageResizingMode {
    #[doc(alias = "UIImageResizingModeTile")]
    pub const Tile: Self = Self(0);
    #[doc(alias = "UIImageResizingModeStretch")]
    pub const Stretch: Self = Self(1);
}

unsafe impl Encode for UIImageResizingMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImageResizingMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIImageRenderingMode(pub NSInteger);
impl UIImageRenderingMode {
    #[doc(alias = "UIImageRenderingModeAutomatic")]
    pub const Automatic: Self = Self(0);
    #[doc(alias = "UIImageRenderingModeAlwaysOriginal")]
    pub const AlwaysOriginal: Self = Self(1);
    #[doc(alias = "UIImageRenderingModeAlwaysTemplate")]
    pub const AlwaysTemplate: Self = Self(2);
}

unsafe impl Encode for UIImageRenderingMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UIImageRenderingMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UIImage;

    unsafe impl ClassType for UIImage {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl Send for UIImage {}

unsafe impl Sync for UIImage {}

unsafe impl NSCoding for UIImage {}

unsafe impl NSObjectProtocol for UIImage {}

unsafe impl NSSecureCoding for UIImage {}

extern_methods!(
    unsafe impl UIImage {
        #[method_id(@__retain_semantics Other systemImageNamed:)]
        pub unsafe fn systemImageNamed(name: &NSString) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIImageConfiguration")]
        #[method_id(@__retain_semantics Other systemImageNamed:withConfiguration:)]
        pub unsafe fn systemImageNamed_withConfiguration(
            name: &NSString,
            configuration: Option<&UIImageConfiguration>,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UITraitCollection")]
        #[method_id(@__retain_semantics Other systemImageNamed:compatibleWithTraitCollection:)]
        pub unsafe fn systemImageNamed_compatibleWithTraitCollection(
            name: &NSString,
            trait_collection: Option<&UITraitCollection>,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIImageConfiguration")]
        #[method_id(@__retain_semantics Other systemImageNamed:variableValue:withConfiguration:)]
        pub unsafe fn systemImageNamed_variableValue_withConfiguration(
            name: &NSString,
            value: c_double,
            configuration: Option<&UIImageConfiguration>,
        ) -> Option<Retained<UIImage>>;

        #[method_id(@__retain_semantics Other imageNamed:)]
        pub unsafe fn imageNamed(name: &NSString) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIImageConfiguration")]
        #[method_id(@__retain_semantics Other imageNamed:inBundle:withConfiguration:)]
        pub unsafe fn imageNamed_inBundle_withConfiguration(
            name: &NSString,
            bundle: Option<&NSBundle>,
            configuration: Option<&UIImageConfiguration>,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UITraitCollection")]
        #[method_id(@__retain_semantics Other imageNamed:inBundle:compatibleWithTraitCollection:)]
        pub unsafe fn imageNamed_inBundle_compatibleWithTraitCollection(
            name: &NSString,
            bundle: Option<&NSBundle>,
            trait_collection: Option<&UITraitCollection>,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIImageConfiguration")]
        #[method_id(@__retain_semantics Other imageNamed:inBundle:variableValue:withConfiguration:)]
        pub unsafe fn imageNamed_inBundle_variableValue_withConfiguration(
            name: &NSString,
            bundle: Option<&NSBundle>,
            value: c_double,
            configuration: Option<&UIImageConfiguration>,
        ) -> Option<Retained<UIImage>>;

        #[method_id(@__retain_semantics Other imageWithContentsOfFile:)]
        pub unsafe fn imageWithContentsOfFile(path: &NSString) -> Option<Retained<UIImage>>;

        #[method_id(@__retain_semantics Other imageWithData:)]
        pub unsafe fn imageWithData(data: &NSData) -> Option<Retained<UIImage>>;

        #[method_id(@__retain_semantics Other imageWithData:scale:)]
        pub unsafe fn imageWithData_scale(
            data: &NSData,
            scale: CGFloat,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "objc2-core-image")]
        #[cfg(not(target_os = "watchos"))]
        #[method_id(@__retain_semantics Other imageWithCIImage:)]
        pub unsafe fn imageWithCIImage(ci_image: &CIImage) -> Retained<UIImage>;

        #[cfg(feature = "objc2-core-image")]
        #[cfg(not(target_os = "watchos"))]
        #[method_id(@__retain_semantics Other imageWithCIImage:scale:orientation:)]
        pub unsafe fn imageWithCIImage_scale_orientation(
            ci_image: &CIImage,
            scale: CGFloat,
            orientation: UIImageOrientation,
        ) -> Retained<UIImage>;

        #[method_id(@__retain_semantics Init initWithContentsOfFile:)]
        pub unsafe fn initWithContentsOfFile(
            this: Allocated<Self>,
            path: &NSString,
        ) -> Option<Retained<Self>>;

        #[method_id(@__retain_semantics Init initWithData:)]
        pub unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;

        #[method_id(@__retain_semantics Init initWithData:scale:)]
        pub unsafe fn initWithData_scale(
            this: Allocated<Self>,
            data: &NSData,
            scale: CGFloat,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "objc2-core-image")]
        #[cfg(not(target_os = "watchos"))]
        #[method_id(@__retain_semantics Init initWithCIImage:)]
        pub unsafe fn initWithCIImage(this: Allocated<Self>, ci_image: &CIImage) -> Retained<Self>;

        #[cfg(feature = "objc2-core-image")]
        #[cfg(not(target_os = "watchos"))]
        #[method_id(@__retain_semantics Init initWithCIImage:scale:orientation:)]
        pub unsafe fn initWithCIImage_scale_orientation(
            this: Allocated<Self>,
            ci_image: &CIImage,
            scale: CGFloat,
            orientation: UIImageOrientation,
        ) -> Retained<Self>;

        #[method(size)]
        pub unsafe fn size(&self) -> CGSize;

        #[cfg(feature = "objc2-core-image")]
        #[cfg(not(target_os = "watchos"))]
        #[method_id(@__retain_semantics Other CIImage)]
        pub unsafe fn CIImage(&self) -> Option<Retained<CIImage>>;

        #[method(imageOrientation)]
        pub unsafe fn imageOrientation(&self) -> UIImageOrientation;

        #[method(scale)]
        pub unsafe fn scale(&self) -> CGFloat;

        #[method(isSymbolImage)]
        pub unsafe fn isSymbolImage(&self) -> bool;

        #[method_id(@__retain_semantics Other animatedImageNamed:duration:)]
        pub unsafe fn animatedImageNamed_duration(
            name: &NSString,
            duration: NSTimeInterval,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIGeometry")]
        #[method_id(@__retain_semantics Other animatedResizableImageNamed:capInsets:duration:)]
        pub unsafe fn animatedResizableImageNamed_capInsets_duration(
            name: &NSString,
            cap_insets: UIEdgeInsets,
            duration: NSTimeInterval,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIGeometry")]
        #[method_id(@__retain_semantics Other animatedResizableImageNamed:capInsets:resizingMode:duration:)]
        pub unsafe fn animatedResizableImageNamed_capInsets_resizingMode_duration(
            name: &NSString,
            cap_insets: UIEdgeInsets,
            resizing_mode: UIImageResizingMode,
            duration: NSTimeInterval,
        ) -> Option<Retained<UIImage>>;

        #[method_id(@__retain_semantics Other animatedImageWithImages:duration:)]
        pub unsafe fn animatedImageWithImages_duration(
            images: &NSArray<UIImage>,
            duration: NSTimeInterval,
        ) -> Option<Retained<UIImage>>;

        #[method_id(@__retain_semantics Other images)]
        pub unsafe fn images(&self) -> Option<Retained<NSArray<UIImage>>>;

        #[method(duration)]
        pub unsafe fn duration(&self) -> NSTimeInterval;

        #[method(drawAtPoint:)]
        pub unsafe fn drawAtPoint(&self, point: CGPoint);

        #[method(drawInRect:)]
        pub unsafe fn drawInRect(&self, rect: CGRect);

        #[method(drawAsPatternInRect:)]
        pub unsafe fn drawAsPatternInRect(&self, rect: CGRect);

        #[cfg(feature = "UIGeometry")]
        #[method_id(@__retain_semantics Other resizableImageWithCapInsets:)]
        pub unsafe fn resizableImageWithCapInsets(
            &self,
            cap_insets: UIEdgeInsets,
        ) -> Retained<UIImage>;

        #[cfg(feature = "UIGeometry")]
        #[method_id(@__retain_semantics Other resizableImageWithCapInsets:resizingMode:)]
        pub unsafe fn resizableImageWithCapInsets_resizingMode(
            &self,
            cap_insets: UIEdgeInsets,
            resizing_mode: UIImageResizingMode,
        ) -> Retained<UIImage>;

        #[cfg(feature = "UIGeometry")]
        #[method(capInsets)]
        pub unsafe fn capInsets(&self) -> UIEdgeInsets;

        #[method(resizingMode)]
        pub unsafe fn resizingMode(&self) -> UIImageResizingMode;

        #[cfg(feature = "UIGeometry")]
        #[method_id(@__retain_semantics Other imageWithAlignmentRectInsets:)]
        pub unsafe fn imageWithAlignmentRectInsets(
            &self,
            alignment_insets: UIEdgeInsets,
        ) -> Retained<UIImage>;

        #[cfg(feature = "UIGeometry")]
        #[method(alignmentRectInsets)]
        pub unsafe fn alignmentRectInsets(&self) -> UIEdgeInsets;

        #[method_id(@__retain_semantics Other imageWithRenderingMode:)]
        pub unsafe fn imageWithRenderingMode(
            &self,
            rendering_mode: UIImageRenderingMode,
        ) -> Retained<UIImage>;

        #[method(renderingMode)]
        pub unsafe fn renderingMode(&self) -> UIImageRenderingMode;

        #[cfg(all(feature = "UIGraphicsImageRenderer", feature = "UIGraphicsRenderer"))]
        #[method_id(@__retain_semantics Other imageRendererFormat)]
        pub unsafe fn imageRendererFormat(&self) -> Retained<UIGraphicsImageRendererFormat>;

        #[cfg(feature = "UITraitCollection")]
        #[method_id(@__retain_semantics Other traitCollection)]
        pub unsafe fn traitCollection(&self) -> Retained<UITraitCollection>;

        #[cfg(feature = "UIImageAsset")]
        #[method_id(@__retain_semantics Other imageAsset)]
        pub unsafe fn imageAsset(&self) -> Option<Retained<UIImageAsset>>;

        #[method_id(@__retain_semantics Other imageFlippedForRightToLeftLayoutDirection)]
        pub unsafe fn imageFlippedForRightToLeftLayoutDirection(&self) -> Retained<UIImage>;

        #[method(flipsForRightToLeftLayoutDirection)]
        pub unsafe fn flipsForRightToLeftLayoutDirection(&self) -> bool;

        #[method_id(@__retain_semantics Other imageWithHorizontallyFlippedOrientation)]
        pub unsafe fn imageWithHorizontallyFlippedOrientation(&self) -> Retained<UIImage>;

        #[method(baselineOffsetFromBottom)]
        pub unsafe fn baselineOffsetFromBottom(&self) -> CGFloat;

        #[method(hasBaseline)]
        pub unsafe fn hasBaseline(&self) -> bool;

        #[method_id(@__retain_semantics Other imageWithBaselineOffsetFromBottom:)]
        pub unsafe fn imageWithBaselineOffsetFromBottom(
            &self,
            baseline_offset: CGFloat,
        ) -> Retained<UIImage>;

        #[method_id(@__retain_semantics Other imageWithoutBaseline)]
        pub unsafe fn imageWithoutBaseline(&self) -> Retained<UIImage>;

        #[cfg(feature = "UIImageConfiguration")]
        #[method_id(@__retain_semantics Other configuration)]
        pub unsafe fn configuration(&self) -> Option<Retained<UIImageConfiguration>>;

        #[cfg(feature = "UIImageConfiguration")]
        #[method_id(@__retain_semantics Other imageWithConfiguration:)]
        pub unsafe fn imageWithConfiguration(
            &self,
            configuration: &UIImageConfiguration,
        ) -> Retained<UIImage>;

        #[cfg(all(
            feature = "UIImageConfiguration",
            feature = "UIImageSymbolConfiguration"
        ))]
        #[method_id(@__retain_semantics Other symbolConfiguration)]
        pub unsafe fn symbolConfiguration(&self) -> Option<Retained<UIImageSymbolConfiguration>>;

        #[cfg(all(
            feature = "UIImageConfiguration",
            feature = "UIImageSymbolConfiguration"
        ))]
        #[method_id(@__retain_semantics Other imageByApplyingSymbolConfiguration:)]
        pub unsafe fn imageByApplyingSymbolConfiguration(
            &self,
            configuration: &UIImageSymbolConfiguration,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIColor")]
        #[method_id(@__retain_semantics Other imageWithTintColor:)]
        pub unsafe fn imageWithTintColor(&self, color: &UIColor) -> Retained<UIImage>;

        #[cfg(feature = "UIColor")]
        #[method_id(@__retain_semantics Other imageWithTintColor:renderingMode:)]
        pub unsafe fn imageWithTintColor_renderingMode(
            &self,
            color: &UIColor,
            rendering_mode: UIImageRenderingMode,
        ) -> Retained<UIImage>;

        #[method_id(@__retain_semantics Other imageByPreparingForDisplay)]
        pub unsafe fn imageByPreparingForDisplay(&self) -> Option<Retained<UIImage>>;

        #[cfg(feature = "block2")]
        #[method(prepareForDisplayWithCompletionHandler:)]
        pub unsafe fn prepareForDisplayWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(*mut UIImage)>,
        );

        #[method_id(@__retain_semantics Other imageByPreparingThumbnailOfSize:)]
        pub unsafe fn imageByPreparingThumbnailOfSize(
            &self,
            size: CGSize,
        ) -> Option<Retained<UIImage>>;

        #[cfg(feature = "block2")]
        #[method(prepareThumbnailOfSize:completionHandler:)]
        pub unsafe fn prepareThumbnailOfSize_completionHandler(
            &self,
            size: CGSize,
            completion_handler: &block2::Block<dyn Fn(*mut UIImage)>,
        );

        #[method(isHighDynamicRange)]
        pub unsafe fn isHighDynamicRange(&self) -> bool;

        #[method_id(@__retain_semantics Other imageRestrictedToStandardDynamicRange)]
        pub unsafe fn imageRestrictedToStandardDynamicRange(&self) -> Retained<UIImage>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UIImage {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_methods!(
    /// PreconfiguredSystemImages
    unsafe impl UIImage {
        #[method_id(@__retain_semantics Other actionsImage)]
        pub unsafe fn actionsImage() -> Retained<UIImage>;

        #[method_id(@__retain_semantics Other addImage)]
        pub unsafe fn addImage() -> Retained<UIImage>;

        #[method_id(@__retain_semantics Other removeImage)]
        pub unsafe fn removeImage() -> Retained<UIImage>;

        #[method_id(@__retain_semantics Other checkmarkImage)]
        pub unsafe fn checkmarkImage() -> Retained<UIImage>;

        #[method_id(@__retain_semantics Other strokedCheckmarkImage)]
        pub unsafe fn strokedCheckmarkImage() -> Retained<UIImage>;
    }
);

extern_methods!(
    /// NSItemProvider
    unsafe impl UIImage {}
);

unsafe impl NSItemProviderReading for UIImage {}

unsafe impl NSItemProviderWriting for UIImage {}

extern_methods!(
    /// UIImage
    #[cfg(feature = "NSTextAttachment")]
    unsafe impl NSTextAttachment {
        #[method_id(@__retain_semantics Other textAttachmentWithImage:)]
        pub unsafe fn textAttachmentWithImage(image: &UIImage) -> Retained<NSTextAttachment>;
    }
);

extern_methods!(
    /// UIImageDeprecated
    unsafe impl UIImage {
        #[method_id(@__retain_semantics Other stretchableImageWithLeftCapWidth:topCapHeight:)]
        pub unsafe fn stretchableImageWithLeftCapWidth_topCapHeight(
            &self,
            left_cap_width: NSInteger,
            top_cap_height: NSInteger,
        ) -> Retained<UIImage>;

        #[method(leftCapWidth)]
        pub unsafe fn leftCapWidth(&self) -> NSInteger;

        #[method(topCapHeight)]
        pub unsafe fn topCapHeight(&self) -> NSInteger;
    }
);

extern_category!(
    /// Category "UIKitAdditions" on [`CIImage`].
    #[doc(alias = "UIKitAdditions")]
    pub unsafe trait CIImageUIKitAdditions {
        #[method_id(@__retain_semantics Init initWithImage:)]
        unsafe fn initWithImage(this: Allocated<Self>, image: &UIImage) -> Option<Retained<Self>>;

        #[cfg(feature = "objc2-core-image")]
        #[cfg(not(target_os = "watchos"))]
        #[method_id(@__retain_semantics Init initWithImage:options:)]
        unsafe fn initWithImage_options(
            this: Allocated<Self>,
            image: &UIImage,
            options: Option<&NSDictionary<CIImageOption, AnyObject>>,
        ) -> Option<Retained<Self>>;
    }

    #[cfg(feature = "objc2-core-image")]
    #[cfg(not(target_os = "watchos"))]
    unsafe impl CIImageUIKitAdditions for CIImage {}
);

extern "C" {
    pub fn UIImagePNGRepresentation(image: &UIImage) -> *mut NSData;
}

extern "C" {
    pub fn UIImageJPEGRepresentation(image: &UIImage, compression_quality: CGFloat) -> *mut NSData;
}

extern "C" {
    pub fn UIImageHEICRepresentation(image: &UIImage) -> *mut NSData;
}