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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTIFFCompression(pub NSUInteger);
impl NSTIFFCompression {
    #[doc(alias = "NSTIFFCompressionNone")]
    pub const None: Self = Self(1);
    #[doc(alias = "NSTIFFCompressionCCITTFAX3")]
    pub const CCITTFAX3: Self = Self(3);
    #[doc(alias = "NSTIFFCompressionCCITTFAX4")]
    pub const CCITTFAX4: Self = Self(4);
    #[doc(alias = "NSTIFFCompressionLZW")]
    pub const LZW: Self = Self(5);
    #[doc(alias = "NSTIFFCompressionJPEG")]
    pub const JPEG: Self = Self(6);
    #[doc(alias = "NSTIFFCompressionNEXT")]
    pub const NEXT: Self = Self(32766);
    #[doc(alias = "NSTIFFCompressionPackBits")]
    pub const PackBits: Self = Self(32773);
    #[doc(alias = "NSTIFFCompressionOldJPEG")]
    pub const OldJPEG: Self = Self(32865);
}

unsafe impl Encode for NSTIFFCompression {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSBitmapImageFileType(pub NSUInteger);
impl NSBitmapImageFileType {
    #[doc(alias = "NSBitmapImageFileTypeTIFF")]
    pub const TIFF: Self = Self(0);
    #[doc(alias = "NSBitmapImageFileTypeBMP")]
    pub const BMP: Self = Self(1);
    #[doc(alias = "NSBitmapImageFileTypeGIF")]
    pub const GIF: Self = Self(2);
    #[doc(alias = "NSBitmapImageFileTypeJPEG")]
    pub const JPEG: Self = Self(3);
    #[doc(alias = "NSBitmapImageFileTypePNG")]
    pub const PNG: Self = Self(4);
    #[doc(alias = "NSBitmapImageFileTypeJPEG2000")]
    pub const JPEG2000: Self = Self(5);
}

unsafe impl Encode for NSBitmapImageFileType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSImageRepLoadStatus(pub NSInteger);
impl NSImageRepLoadStatus {
    #[doc(alias = "NSImageRepLoadStatusUnknownType")]
    pub const UnknownType: Self = Self(-1);
    #[doc(alias = "NSImageRepLoadStatusReadingHeader")]
    pub const ReadingHeader: Self = Self(-2);
    #[doc(alias = "NSImageRepLoadStatusWillNeedAllData")]
    pub const WillNeedAllData: Self = Self(-3);
    #[doc(alias = "NSImageRepLoadStatusInvalidData")]
    pub const InvalidData: Self = Self(-4);
    #[doc(alias = "NSImageRepLoadStatusUnexpectedEOF")]
    pub const UnexpectedEOF: Self = Self(-5);
    #[doc(alias = "NSImageRepLoadStatusCompleted")]
    pub const Completed: Self = Self(-6);
}

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

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

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSBitmapFormat(pub NSUInteger);
impl NSBitmapFormat {
    #[doc(alias = "NSBitmapFormatAlphaFirst")]
    pub const AlphaFirst: Self = Self(1 << 0);
    #[doc(alias = "NSBitmapFormatAlphaNonpremultiplied")]
    pub const AlphaNonpremultiplied: Self = Self(1 << 1);
    #[doc(alias = "NSBitmapFormatFloatingPointSamples")]
    pub const FloatingPointSamples: Self = Self(1 << 2);
    #[doc(alias = "NSBitmapFormatSixteenBitLittleEndian")]
    pub const SixteenBitLittleEndian: Self = Self(1 << 8);
    #[doc(alias = "NSBitmapFormatThirtyTwoBitLittleEndian")]
    pub const ThirtyTwoBitLittleEndian: Self = Self(1 << 9);
    #[doc(alias = "NSBitmapFormatSixteenBitBigEndian")]
    pub const SixteenBitBigEndian: Self = Self(1 << 10);
    #[doc(alias = "NSBitmapFormatThirtyTwoBitBigEndian")]
    pub const ThirtyTwoBitBigEndian: Self = Self(1 << 11);
}

unsafe impl Encode for NSBitmapFormat {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

// NS_TYPED_EXTENSIBLE_ENUM
pub type NSBitmapImageRepPropertyKey = NSString;

extern "C" {
    pub static NSImageCompressionMethod: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageCompressionFactor: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageDitherTransparency: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageRGBColorTable: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageInterlaced: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageColorSyncProfileData: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageFrameCount: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageCurrentFrame: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageCurrentFrameDuration: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageLoopCount: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageGamma: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageProgressive: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageEXIFData: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageIPTCData: &'static NSBitmapImageRepPropertyKey;
}

extern "C" {
    pub static NSImageFallbackBackgroundColor: &'static NSBitmapImageRepPropertyKey;
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSImageRep")]
    pub struct NSBitmapImageRep;

    #[cfg(feature = "NSImageRep")]
    unsafe impl ClassType for NSBitmapImageRep {
        #[inherits(NSObject)]
        type Super = NSImageRep;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "NSImageRep")]
unsafe impl NSCoding for NSBitmapImageRep {}

#[cfg(feature = "NSImageRep")]
unsafe impl NSCopying for NSBitmapImageRep {}

#[cfg(feature = "NSImageRep")]
unsafe impl NSObjectProtocol for NSBitmapImageRep {}

#[cfg(feature = "NSImageRep")]
unsafe impl NSSecureCoding for NSBitmapImageRep {}

extern_methods!(
    #[cfg(feature = "NSImageRep")]
    unsafe impl NSBitmapImageRep {
        #[deprecated = "Use -[NSView cacheDisplayInRect:toBitmapImageRep:] to snapshot a view."]
        #[method_id(@__retain_semantics Init initWithFocusedViewRect:)]
        pub unsafe fn initWithFocusedViewRect(
            this: Allocated<Self>,
            rect: NSRect,
        ) -> Option<Id<Self>>;

        #[cfg(feature = "NSGraphics")]
        #[method_id(@__retain_semantics Init initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:)]
        pub unsafe fn initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel(
            this: Allocated<Self>,
            planes: *mut *mut c_uchar,
            width: NSInteger,
            height: NSInteger,
            bps: NSInteger,
            spp: NSInteger,
            alpha: bool,
            is_planar: bool,
            color_space_name: &NSColorSpaceName,
            r_bytes: NSInteger,
            p_bits: NSInteger,
        ) -> Option<Id<Self>>;

        #[cfg(feature = "NSGraphics")]
        #[method_id(@__retain_semantics Init initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel:)]
        pub unsafe fn initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel(
            this: Allocated<Self>,
            planes: *mut *mut c_uchar,
            width: NSInteger,
            height: NSInteger,
            bps: NSInteger,
            spp: NSInteger,
            alpha: bool,
            is_planar: bool,
            color_space_name: &NSColorSpaceName,
            bitmap_format: NSBitmapFormat,
            r_bytes: NSInteger,
            p_bits: NSInteger,
        ) -> Option<Id<Self>>;

        #[method_id(@__retain_semantics Other imageRepsWithData:)]
        pub unsafe fn imageRepsWithData(data: &NSData) -> Id<NSArray<NSImageRep>>;

        #[method_id(@__retain_semantics Other imageRepWithData:)]
        pub unsafe fn imageRepWithData(data: &NSData) -> Option<Id<Self>>;

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

        #[method(bitmapData)]
        pub unsafe fn bitmapData(&self) -> *mut c_uchar;

        #[method(getBitmapDataPlanes:)]
        pub unsafe fn getBitmapDataPlanes(&self, data: NonNull<*mut c_uchar>);

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

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

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

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

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

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

        #[method(bitmapFormat)]
        pub unsafe fn bitmapFormat(&self) -> NSBitmapFormat;

        #[method(getCompression:factor:)]
        pub unsafe fn getCompression_factor(
            &self,
            compression: *mut NSTIFFCompression,
            factor: *mut c_float,
        );

        #[method(setCompression:factor:)]
        pub unsafe fn setCompression_factor(&self, compression: NSTIFFCompression, factor: c_float);

        #[method_id(@__retain_semantics Other TIFFRepresentation)]
        pub unsafe fn TIFFRepresentation(&self) -> Option<Id<NSData>>;

        #[method_id(@__retain_semantics Other TIFFRepresentationUsingCompression:factor:)]
        pub unsafe fn TIFFRepresentationUsingCompression_factor(
            &self,
            comp: NSTIFFCompression,
            factor: c_float,
        ) -> Option<Id<NSData>>;

        #[method_id(@__retain_semantics Other TIFFRepresentationOfImageRepsInArray:)]
        pub unsafe fn TIFFRepresentationOfImageRepsInArray(
            array: &NSArray<NSImageRep>,
        ) -> Option<Id<NSData>>;

        #[method_id(@__retain_semantics Other TIFFRepresentationOfImageRepsInArray:usingCompression:factor:)]
        pub unsafe fn TIFFRepresentationOfImageRepsInArray_usingCompression_factor(
            array: &NSArray<NSImageRep>,
            comp: NSTIFFCompression,
            factor: c_float,
        ) -> Option<Id<NSData>>;

        #[method(getTIFFCompressionTypes:count:)]
        pub unsafe fn getTIFFCompressionTypes_count(
            list: NonNull<*mut NSTIFFCompression>,
            num_types: NonNull<NSInteger>,
        );

        #[method_id(@__retain_semantics Other localizedNameForTIFFCompressionType:)]
        pub unsafe fn localizedNameForTIFFCompressionType(
            compression: NSTIFFCompression,
        ) -> Option<Id<NSString>>;

        #[method(canBeCompressedUsing:)]
        pub unsafe fn canBeCompressedUsing(&self, compression: NSTIFFCompression) -> bool;

        #[cfg(feature = "NSColor")]
        #[method(colorizeByMappingGray:toColor:blackMapping:whiteMapping:)]
        pub unsafe fn colorizeByMappingGray_toColor_blackMapping_whiteMapping(
            &self,
            mid_point: CGFloat,
            mid_point_color: Option<&NSColor>,
            shadow_color: Option<&NSColor>,
            light_color: Option<&NSColor>,
        );

        #[method_id(@__retain_semantics Init initForIncrementalLoad)]
        pub unsafe fn initForIncrementalLoad(this: Allocated<Self>) -> Id<Self>;

        #[method(incrementalLoadFromData:complete:)]
        pub unsafe fn incrementalLoadFromData_complete(
            &self,
            data: &NSData,
            complete: bool,
        ) -> NSInteger;

        #[cfg(feature = "NSColor")]
        #[method(setColor:atX:y:)]
        pub unsafe fn setColor_atX_y(&self, color: &NSColor, x: NSInteger, y: NSInteger);

        #[cfg(feature = "NSColor")]
        #[method_id(@__retain_semantics Other colorAtX:y:)]
        pub unsafe fn colorAtX_y(&self, x: NSInteger, y: NSInteger) -> Option<Id<NSColor>>;

        #[method(getPixel:atX:y:)]
        pub unsafe fn getPixel_atX_y(&self, p: NonNull<NSUInteger>, x: NSInteger, y: NSInteger);

        #[method(setPixel:atX:y:)]
        pub unsafe fn setPixel_atX_y(&self, p: NonNull<NSUInteger>, x: NSInteger, y: NSInteger);

        #[cfg(feature = "NSColorSpace")]
        #[method_id(@__retain_semantics Other colorSpace)]
        pub unsafe fn colorSpace(&self) -> Id<NSColorSpace>;

        #[cfg(all(feature = "NSColorSpace", feature = "NSGraphics"))]
        #[method_id(@__retain_semantics Other bitmapImageRepByConvertingToColorSpace:renderingIntent:)]
        pub unsafe fn bitmapImageRepByConvertingToColorSpace_renderingIntent(
            &self,
            target_space: &NSColorSpace,
            rendering_intent: NSColorRenderingIntent,
        ) -> Option<Id<NSBitmapImageRep>>;

        #[cfg(feature = "NSColorSpace")]
        #[method_id(@__retain_semantics Other bitmapImageRepByRetaggingWithColorSpace:)]
        pub unsafe fn bitmapImageRepByRetaggingWithColorSpace(
            &self,
            new_space: &NSColorSpace,
        ) -> Option<Id<NSBitmapImageRep>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSImageRep`
    #[cfg(feature = "NSImageRep")]
    unsafe impl NSBitmapImageRep {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Id<Self>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "NSImageRep")]
    unsafe impl NSBitmapImageRep {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);

extern_methods!(
    /// NSBitmapImageFileTypeExtensions
    #[cfg(feature = "NSImageRep")]
    unsafe impl NSBitmapImageRep {
        #[method_id(@__retain_semantics Other representationOfImageRepsInArray:usingType:properties:)]
        pub unsafe fn representationOfImageRepsInArray_usingType_properties(
            image_reps: &NSArray<NSImageRep>,
            storage_type: NSBitmapImageFileType,
            properties: &NSDictionary<NSBitmapImageRepPropertyKey, AnyObject>,
        ) -> Option<Id<NSData>>;

        #[method_id(@__retain_semantics Other representationUsingType:properties:)]
        pub unsafe fn representationUsingType_properties(
            &self,
            storage_type: NSBitmapImageFileType,
            properties: &NSDictionary<NSBitmapImageRepPropertyKey, AnyObject>,
        ) -> Option<Id<NSData>>;

        #[method(setProperty:withValue:)]
        pub unsafe fn setProperty_withValue(
            &self,
            property: &NSBitmapImageRepPropertyKey,
            value: Option<&AnyObject>,
        );

        #[method_id(@__retain_semantics Other valueForProperty:)]
        pub unsafe fn valueForProperty(
            &self,
            property: &NSBitmapImageRepPropertyKey,
        ) -> Option<Id<AnyObject>>;
    }
);

pub static NSTIFFFileType: NSBitmapImageFileType =
    NSBitmapImageFileType(NSBitmapImageFileType::TIFF.0);

pub static NSBMPFileType: NSBitmapImageFileType =
    NSBitmapImageFileType(NSBitmapImageFileType::BMP.0);

pub static NSGIFFileType: NSBitmapImageFileType =
    NSBitmapImageFileType(NSBitmapImageFileType::GIF.0);

pub static NSJPEGFileType: NSBitmapImageFileType =
    NSBitmapImageFileType(NSBitmapImageFileType::JPEG.0);

pub static NSPNGFileType: NSBitmapImageFileType =
    NSBitmapImageFileType(NSBitmapImageFileType::PNG.0);

pub static NSJPEG2000FileType: NSBitmapImageFileType =
    NSBitmapImageFileType(NSBitmapImageFileType::JPEG2000.0);

pub static NSAlphaFirstBitmapFormat: NSBitmapFormat = NSBitmapFormat(NSBitmapFormat::AlphaFirst.0);

pub static NSAlphaNonpremultipliedBitmapFormat: NSBitmapFormat =
    NSBitmapFormat(NSBitmapFormat::AlphaNonpremultiplied.0);

pub static NSFloatingPointSamplesBitmapFormat: NSBitmapFormat =
    NSBitmapFormat(NSBitmapFormat::FloatingPointSamples.0);

pub static NS16BitLittleEndianBitmapFormat: NSBitmapFormat =
    NSBitmapFormat(NSBitmapFormat::SixteenBitLittleEndian.0);

pub static NS32BitLittleEndianBitmapFormat: NSBitmapFormat =
    NSBitmapFormat(NSBitmapFormat::ThirtyTwoBitLittleEndian.0);

pub static NS16BitBigEndianBitmapFormat: NSBitmapFormat =
    NSBitmapFormat(NSBitmapFormat::SixteenBitBigEndian.0);

pub static NS32BitBigEndianBitmapFormat: NSBitmapFormat =
    NSBitmapFormat(NSBitmapFormat::ThirtyTwoBitBigEndian.0);