1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13#[repr(C)]
15pub struct CGImage {
16 inner: [u8; 0],
17 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21 unsafe impl CGImage {}
22);
23#[cfg(feature = "objc2")]
24cf_objc2_type!(
25 unsafe impl RefEncode<"CGImage"> for CGImage {}
26);
27
28#[repr(transparent)]
31#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
32pub struct CGImageAlphaInfo(pub u32);
33impl CGImageAlphaInfo {
34 #[doc(alias = "kCGImageAlphaNone")]
35 pub const None: Self = Self(0);
36 #[doc(alias = "kCGImageAlphaPremultipliedLast")]
37 pub const PremultipliedLast: Self = Self(1);
38 #[doc(alias = "kCGImageAlphaPremultipliedFirst")]
39 pub const PremultipliedFirst: Self = Self(2);
40 #[doc(alias = "kCGImageAlphaLast")]
41 pub const Last: Self = Self(3);
42 #[doc(alias = "kCGImageAlphaFirst")]
43 pub const First: Self = Self(4);
44 #[doc(alias = "kCGImageAlphaNoneSkipLast")]
45 pub const NoneSkipLast: Self = Self(5);
46 #[doc(alias = "kCGImageAlphaNoneSkipFirst")]
47 pub const NoneSkipFirst: Self = Self(6);
48 #[doc(alias = "kCGImageAlphaOnly")]
49 pub const Only: Self = Self(7);
50}
51
52#[cfg(feature = "objc2")]
53unsafe impl Encode for CGImageAlphaInfo {
54 const ENCODING: Encoding = u32::ENCODING;
55}
56
57#[cfg(feature = "objc2")]
58unsafe impl RefEncode for CGImageAlphaInfo {
59 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
60}
61
62#[repr(transparent)]
65#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
66pub struct CGImageByteOrderInfo(pub u32);
67impl CGImageByteOrderInfo {
68 #[doc(alias = "kCGImageByteOrderMask")]
69 pub const OrderMask: Self = Self(0x7000);
70 #[doc(alias = "kCGImageByteOrderDefault")]
71 pub const OrderDefault: Self = Self(0 << 12);
72 #[doc(alias = "kCGImageByteOrder16Little")]
73 pub const Order16Little: Self = Self(1 << 12);
74 #[doc(alias = "kCGImageByteOrder32Little")]
75 pub const Order32Little: Self = Self(2 << 12);
76 #[doc(alias = "kCGImageByteOrder16Big")]
77 pub const Order16Big: Self = Self(3 << 12);
78 #[doc(alias = "kCGImageByteOrder32Big")]
79 pub const Order32Big: Self = Self(4 << 12);
80}
81
82#[cfg(feature = "objc2")]
83unsafe impl Encode for CGImageByteOrderInfo {
84 const ENCODING: Encoding = u32::ENCODING;
85}
86
87#[cfg(feature = "objc2")]
88unsafe impl RefEncode for CGImageByteOrderInfo {
89 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
90}
91
92#[repr(transparent)]
95#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
96pub struct CGImagePixelFormatInfo(pub u32);
97impl CGImagePixelFormatInfo {
98 #[doc(alias = "kCGImagePixelFormatMask")]
99 pub const Mask: Self = Self(0xF0000);
100 #[doc(alias = "kCGImagePixelFormatPacked")]
101 pub const Packed: Self = Self(0 << 16);
102 #[doc(alias = "kCGImagePixelFormatRGB555")]
103 pub const RGB555: Self = Self(1 << 16);
104 #[doc(alias = "kCGImagePixelFormatRGB565")]
105 pub const RGB565: Self = Self(2 << 16);
106 #[doc(alias = "kCGImagePixelFormatRGB101010")]
107 pub const RGB101010: Self = Self(3 << 16);
108 #[doc(alias = "kCGImagePixelFormatRGBCIF10")]
109 pub const RGBCIF10: Self = Self(4 << 16);
110}
111
112#[cfg(feature = "objc2")]
113unsafe impl Encode for CGImagePixelFormatInfo {
114 const ENCODING: Encoding = u32::ENCODING;
115}
116
117#[cfg(feature = "objc2")]
118unsafe impl RefEncode for CGImagePixelFormatInfo {
119 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
120}
121
122#[repr(transparent)]
125#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
126pub struct CGBitmapInfo(pub u32);
127bitflags::bitflags! {
128 impl CGBitmapInfo: u32 {
129 #[doc(alias = "kCGBitmapAlphaInfoMask")]
130 const AlphaInfoMask = 0x1F;
131 #[doc(alias = "kCGBitmapFloatInfoMask")]
132 const FloatInfoMask = 0xF00;
133 #[doc(alias = "kCGBitmapFloatComponents")]
134 const FloatComponents = 1<<8;
135 #[doc(alias = "kCGBitmapByteOrderMask")]
136 const ByteOrderMask = CGImageByteOrderInfo::OrderMask.0;
137 #[doc(alias = "kCGBitmapByteOrderDefault")]
138 const ByteOrderDefault = CGImageByteOrderInfo::OrderDefault.0;
139 #[doc(alias = "kCGBitmapByteOrder16Little")]
140 const ByteOrder16Little = CGImageByteOrderInfo::Order16Little.0;
141 #[doc(alias = "kCGBitmapByteOrder32Little")]
142 const ByteOrder32Little = CGImageByteOrderInfo::Order32Little.0;
143 #[doc(alias = "kCGBitmapByteOrder16Big")]
144 const ByteOrder16Big = CGImageByteOrderInfo::Order16Big.0;
145 #[doc(alias = "kCGBitmapByteOrder32Big")]
146 const ByteOrder32Big = CGImageByteOrderInfo::Order32Big.0;
147 }
148}
149
150#[cfg(feature = "objc2")]
151unsafe impl Encode for CGBitmapInfo {
152 const ENCODING: Encoding = u32::ENCODING;
153}
154
155#[cfg(feature = "objc2")]
156unsafe impl RefEncode for CGBitmapInfo {
157 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
158}
159
160unsafe impl ConcreteType for CGImage {
161 #[doc(alias = "CGImageGetTypeID")]
162 #[inline]
163 fn type_id() -> CFTypeID {
164 extern "C-unwind" {
165 fn CGImageGetTypeID() -> CFTypeID;
166 }
167 unsafe { CGImageGetTypeID() }
168 }
169}
170
171impl CGImage {
172 #[doc(alias = "CGImageCreate")]
173 #[cfg(all(feature = "CGColorSpace", feature = "CGDataProvider"))]
174 #[inline]
175 pub unsafe fn new(
176 width: usize,
177 height: usize,
178 bits_per_component: usize,
179 bits_per_pixel: usize,
180 bytes_per_row: usize,
181 space: Option<&CGColorSpace>,
182 bitmap_info: CGBitmapInfo,
183 provider: Option<&CGDataProvider>,
184 decode: *const CGFloat,
185 should_interpolate: bool,
186 intent: CGColorRenderingIntent,
187 ) -> Option<CFRetained<CGImage>> {
188 extern "C-unwind" {
189 fn CGImageCreate(
190 width: usize,
191 height: usize,
192 bits_per_component: usize,
193 bits_per_pixel: usize,
194 bytes_per_row: usize,
195 space: Option<&CGColorSpace>,
196 bitmap_info: CGBitmapInfo,
197 provider: Option<&CGDataProvider>,
198 decode: *const CGFloat,
199 should_interpolate: bool,
200 intent: CGColorRenderingIntent,
201 ) -> Option<NonNull<CGImage>>;
202 }
203 let ret = unsafe {
204 CGImageCreate(
205 width,
206 height,
207 bits_per_component,
208 bits_per_pixel,
209 bytes_per_row,
210 space,
211 bitmap_info,
212 provider,
213 decode,
214 should_interpolate,
215 intent,
216 )
217 };
218 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
219 }
220
221 #[doc(alias = "CGImageMaskCreate")]
222 #[cfg(feature = "CGDataProvider")]
223 #[inline]
224 pub unsafe fn mask_create(
225 width: usize,
226 height: usize,
227 bits_per_component: usize,
228 bits_per_pixel: usize,
229 bytes_per_row: usize,
230 provider: Option<&CGDataProvider>,
231 decode: *const CGFloat,
232 should_interpolate: bool,
233 ) -> Option<CFRetained<CGImage>> {
234 extern "C-unwind" {
235 fn CGImageMaskCreate(
236 width: usize,
237 height: usize,
238 bits_per_component: usize,
239 bits_per_pixel: usize,
240 bytes_per_row: usize,
241 provider: Option<&CGDataProvider>,
242 decode: *const CGFloat,
243 should_interpolate: bool,
244 ) -> Option<NonNull<CGImage>>;
245 }
246 let ret = unsafe {
247 CGImageMaskCreate(
248 width,
249 height,
250 bits_per_component,
251 bits_per_pixel,
252 bytes_per_row,
253 provider,
254 decode,
255 should_interpolate,
256 )
257 };
258 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
259 }
260
261 #[doc(alias = "CGImageCreateCopy")]
262 #[inline]
263 pub unsafe fn new_copy(image: Option<&CGImage>) -> Option<CFRetained<CGImage>> {
264 extern "C-unwind" {
265 fn CGImageCreateCopy(image: Option<&CGImage>) -> Option<NonNull<CGImage>>;
266 }
267 let ret = unsafe { CGImageCreateCopy(image) };
268 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
269 }
270
271 #[doc(alias = "CGImageCreateWithJPEGDataProvider")]
272 #[cfg(all(feature = "CGColorSpace", feature = "CGDataProvider"))]
273 #[inline]
274 pub unsafe fn with_jpeg_data_provider(
275 source: Option<&CGDataProvider>,
276 decode: *const CGFloat,
277 should_interpolate: bool,
278 intent: CGColorRenderingIntent,
279 ) -> Option<CFRetained<CGImage>> {
280 extern "C-unwind" {
281 fn CGImageCreateWithJPEGDataProvider(
282 source: Option<&CGDataProvider>,
283 decode: *const CGFloat,
284 should_interpolate: bool,
285 intent: CGColorRenderingIntent,
286 ) -> Option<NonNull<CGImage>>;
287 }
288 let ret = unsafe {
289 CGImageCreateWithJPEGDataProvider(source, decode, should_interpolate, intent)
290 };
291 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
292 }
293
294 #[doc(alias = "CGImageCreateWithPNGDataProvider")]
295 #[cfg(all(feature = "CGColorSpace", feature = "CGDataProvider"))]
296 #[inline]
297 pub unsafe fn with_png_data_provider(
298 source: Option<&CGDataProvider>,
299 decode: *const CGFloat,
300 should_interpolate: bool,
301 intent: CGColorRenderingIntent,
302 ) -> Option<CFRetained<CGImage>> {
303 extern "C-unwind" {
304 fn CGImageCreateWithPNGDataProvider(
305 source: Option<&CGDataProvider>,
306 decode: *const CGFloat,
307 should_interpolate: bool,
308 intent: CGColorRenderingIntent,
309 ) -> Option<NonNull<CGImage>>;
310 }
311 let ret =
312 unsafe { CGImageCreateWithPNGDataProvider(source, decode, should_interpolate, intent) };
313 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
314 }
315
316 #[doc(alias = "CGImageCreateWithImageInRect")]
317 #[inline]
318 pub unsafe fn with_image_in_rect(
319 image: Option<&CGImage>,
320 rect: CGRect,
321 ) -> Option<CFRetained<CGImage>> {
322 extern "C-unwind" {
323 fn CGImageCreateWithImageInRect(
324 image: Option<&CGImage>,
325 rect: CGRect,
326 ) -> Option<NonNull<CGImage>>;
327 }
328 let ret = unsafe { CGImageCreateWithImageInRect(image, rect) };
329 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
330 }
331
332 #[doc(alias = "CGImageCreateWithMask")]
333 #[inline]
334 pub unsafe fn with_mask(
335 image: Option<&CGImage>,
336 mask: Option<&CGImage>,
337 ) -> Option<CFRetained<CGImage>> {
338 extern "C-unwind" {
339 fn CGImageCreateWithMask(
340 image: Option<&CGImage>,
341 mask: Option<&CGImage>,
342 ) -> Option<NonNull<CGImage>>;
343 }
344 let ret = unsafe { CGImageCreateWithMask(image, mask) };
345 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
346 }
347
348 #[doc(alias = "CGImageCreateWithMaskingColors")]
349 #[inline]
350 pub unsafe fn with_masking_colors(
351 image: Option<&CGImage>,
352 components: *const CGFloat,
353 ) -> Option<CFRetained<CGImage>> {
354 extern "C-unwind" {
355 fn CGImageCreateWithMaskingColors(
356 image: Option<&CGImage>,
357 components: *const CGFloat,
358 ) -> Option<NonNull<CGImage>>;
359 }
360 let ret = unsafe { CGImageCreateWithMaskingColors(image, components) };
361 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
362 }
363
364 #[doc(alias = "CGImageCreateCopyWithColorSpace")]
365 #[cfg(feature = "CGColorSpace")]
366 #[inline]
367 pub unsafe fn new_copy_with_color_space(
368 image: Option<&CGImage>,
369 space: Option<&CGColorSpace>,
370 ) -> Option<CFRetained<CGImage>> {
371 extern "C-unwind" {
372 fn CGImageCreateCopyWithColorSpace(
373 image: Option<&CGImage>,
374 space: Option<&CGColorSpace>,
375 ) -> Option<NonNull<CGImage>>;
376 }
377 let ret = unsafe { CGImageCreateCopyWithColorSpace(image, space) };
378 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
379 }
380
381 #[doc(alias = "CGImageCreateWithContentHeadroom")]
382 #[cfg(all(feature = "CGColorSpace", feature = "CGDataProvider"))]
383 #[inline]
384 pub unsafe fn with_content_headroom(
385 headroom: c_float,
386 width: usize,
387 height: usize,
388 bits_per_component: usize,
389 bits_per_pixel: usize,
390 bytes_per_row: usize,
391 space: Option<&CGColorSpace>,
392 bitmap_info: CGBitmapInfo,
393 provider: Option<&CGDataProvider>,
394 decode: *const CGFloat,
395 should_interpolate: bool,
396 intent: CGColorRenderingIntent,
397 ) -> Option<CFRetained<CGImage>> {
398 extern "C-unwind" {
399 fn CGImageCreateWithContentHeadroom(
400 headroom: c_float,
401 width: usize,
402 height: usize,
403 bits_per_component: usize,
404 bits_per_pixel: usize,
405 bytes_per_row: usize,
406 space: Option<&CGColorSpace>,
407 bitmap_info: CGBitmapInfo,
408 provider: Option<&CGDataProvider>,
409 decode: *const CGFloat,
410 should_interpolate: bool,
411 intent: CGColorRenderingIntent,
412 ) -> Option<NonNull<CGImage>>;
413 }
414 let ret = unsafe {
415 CGImageCreateWithContentHeadroom(
416 headroom,
417 width,
418 height,
419 bits_per_component,
420 bits_per_pixel,
421 bytes_per_row,
422 space,
423 bitmap_info,
424 provider,
425 decode,
426 should_interpolate,
427 intent,
428 )
429 };
430 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
431 }
432
433 #[doc(alias = "CGImageCreateCopyWithContentHeadroom")]
434 #[inline]
435 pub unsafe fn new_copy_with_content_headroom(
436 headroom: c_float,
437 image: Option<&CGImage>,
438 ) -> Option<CFRetained<CGImage>> {
439 extern "C-unwind" {
440 fn CGImageCreateCopyWithContentHeadroom(
441 headroom: c_float,
442 image: Option<&CGImage>,
443 ) -> Option<NonNull<CGImage>>;
444 }
445 let ret = unsafe { CGImageCreateCopyWithContentHeadroom(headroom, image) };
446 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
447 }
448}
449
450extern "C" {
451 pub static kCGDefaultHDRImageContentHeadroom: c_float;
453}
454
455impl CGImage {
456 #[doc(alias = "CGImageGetContentHeadroom")]
457 #[inline]
458 pub unsafe fn content_headroom(image: Option<&CGImage>) -> c_float {
459 extern "C-unwind" {
460 fn CGImageGetContentHeadroom(image: Option<&CGImage>) -> c_float;
461 }
462 unsafe { CGImageGetContentHeadroom(image) }
463 }
464
465 #[doc(alias = "CGImageIsMask")]
466 #[inline]
467 pub unsafe fn is_mask(image: Option<&CGImage>) -> bool {
468 extern "C-unwind" {
469 fn CGImageIsMask(image: Option<&CGImage>) -> bool;
470 }
471 unsafe { CGImageIsMask(image) }
472 }
473
474 #[doc(alias = "CGImageGetWidth")]
475 #[inline]
476 pub unsafe fn width(image: Option<&CGImage>) -> usize {
477 extern "C-unwind" {
478 fn CGImageGetWidth(image: Option<&CGImage>) -> usize;
479 }
480 unsafe { CGImageGetWidth(image) }
481 }
482
483 #[doc(alias = "CGImageGetHeight")]
484 #[inline]
485 pub unsafe fn height(image: Option<&CGImage>) -> usize {
486 extern "C-unwind" {
487 fn CGImageGetHeight(image: Option<&CGImage>) -> usize;
488 }
489 unsafe { CGImageGetHeight(image) }
490 }
491
492 #[doc(alias = "CGImageGetBitsPerComponent")]
493 #[inline]
494 pub unsafe fn bits_per_component(image: Option<&CGImage>) -> usize {
495 extern "C-unwind" {
496 fn CGImageGetBitsPerComponent(image: Option<&CGImage>) -> usize;
497 }
498 unsafe { CGImageGetBitsPerComponent(image) }
499 }
500
501 #[doc(alias = "CGImageGetBitsPerPixel")]
502 #[inline]
503 pub unsafe fn bits_per_pixel(image: Option<&CGImage>) -> usize {
504 extern "C-unwind" {
505 fn CGImageGetBitsPerPixel(image: Option<&CGImage>) -> usize;
506 }
507 unsafe { CGImageGetBitsPerPixel(image) }
508 }
509
510 #[doc(alias = "CGImageGetBytesPerRow")]
511 #[inline]
512 pub unsafe fn bytes_per_row(image: Option<&CGImage>) -> usize {
513 extern "C-unwind" {
514 fn CGImageGetBytesPerRow(image: Option<&CGImage>) -> usize;
515 }
516 unsafe { CGImageGetBytesPerRow(image) }
517 }
518
519 #[doc(alias = "CGImageGetColorSpace")]
520 #[cfg(feature = "CGColorSpace")]
521 #[inline]
522 pub unsafe fn color_space(image: Option<&CGImage>) -> Option<CFRetained<CGColorSpace>> {
523 extern "C-unwind" {
524 fn CGImageGetColorSpace(image: Option<&CGImage>) -> Option<NonNull<CGColorSpace>>;
525 }
526 let ret = unsafe { CGImageGetColorSpace(image) };
527 ret.map(|ret| unsafe { CFRetained::retain(ret) })
528 }
529
530 #[doc(alias = "CGImageGetAlphaInfo")]
531 #[inline]
532 pub unsafe fn alpha_info(image: Option<&CGImage>) -> CGImageAlphaInfo {
533 extern "C-unwind" {
534 fn CGImageGetAlphaInfo(image: Option<&CGImage>) -> CGImageAlphaInfo;
535 }
536 unsafe { CGImageGetAlphaInfo(image) }
537 }
538
539 #[doc(alias = "CGImageGetDataProvider")]
540 #[cfg(feature = "CGDataProvider")]
541 #[inline]
542 pub unsafe fn data_provider(image: Option<&CGImage>) -> Option<CFRetained<CGDataProvider>> {
543 extern "C-unwind" {
544 fn CGImageGetDataProvider(image: Option<&CGImage>) -> Option<NonNull<CGDataProvider>>;
545 }
546 let ret = unsafe { CGImageGetDataProvider(image) };
547 ret.map(|ret| unsafe { CFRetained::retain(ret) })
548 }
549
550 #[doc(alias = "CGImageGetDecode")]
551 #[inline]
552 pub unsafe fn decode(image: Option<&CGImage>) -> *const CGFloat {
553 extern "C-unwind" {
554 fn CGImageGetDecode(image: Option<&CGImage>) -> *const CGFloat;
555 }
556 unsafe { CGImageGetDecode(image) }
557 }
558
559 #[doc(alias = "CGImageGetShouldInterpolate")]
560 #[inline]
561 pub unsafe fn should_interpolate(image: Option<&CGImage>) -> bool {
562 extern "C-unwind" {
563 fn CGImageGetShouldInterpolate(image: Option<&CGImage>) -> bool;
564 }
565 unsafe { CGImageGetShouldInterpolate(image) }
566 }
567
568 #[doc(alias = "CGImageGetRenderingIntent")]
569 #[cfg(feature = "CGColorSpace")]
570 #[inline]
571 pub unsafe fn rendering_intent(image: Option<&CGImage>) -> CGColorRenderingIntent {
572 extern "C-unwind" {
573 fn CGImageGetRenderingIntent(image: Option<&CGImage>) -> CGColorRenderingIntent;
574 }
575 unsafe { CGImageGetRenderingIntent(image) }
576 }
577
578 #[doc(alias = "CGImageGetBitmapInfo")]
579 #[inline]
580 pub unsafe fn bitmap_info(image: Option<&CGImage>) -> CGBitmapInfo {
581 extern "C-unwind" {
582 fn CGImageGetBitmapInfo(image: Option<&CGImage>) -> CGBitmapInfo;
583 }
584 unsafe { CGImageGetBitmapInfo(image) }
585 }
586
587 #[doc(alias = "CGImageGetByteOrderInfo")]
588 #[inline]
589 pub unsafe fn byte_order_info(image: Option<&CGImage>) -> CGImageByteOrderInfo {
590 extern "C-unwind" {
591 fn CGImageGetByteOrderInfo(image: Option<&CGImage>) -> CGImageByteOrderInfo;
592 }
593 unsafe { CGImageGetByteOrderInfo(image) }
594 }
595
596 #[doc(alias = "CGImageGetPixelFormatInfo")]
597 #[inline]
598 pub unsafe fn pixel_format_info(image: Option<&CGImage>) -> CGImagePixelFormatInfo {
599 extern "C-unwind" {
600 fn CGImageGetPixelFormatInfo(image: Option<&CGImage>) -> CGImagePixelFormatInfo;
601 }
602 unsafe { CGImageGetPixelFormatInfo(image) }
603 }
604
605 #[doc(alias = "CGImageShouldToneMap")]
606 #[inline]
607 pub unsafe fn should_tone_map(image: Option<&CGImage>) -> bool {
608 extern "C-unwind" {
609 fn CGImageShouldToneMap(image: Option<&CGImage>) -> bool;
610 }
611 unsafe { CGImageShouldToneMap(image) }
612 }
613
614 #[doc(alias = "CGImageContainsImageSpecificToneMappingMetadata")]
615 #[inline]
616 pub unsafe fn contains_image_specific_tone_mapping_metadata(image: Option<&CGImage>) -> bool {
617 extern "C-unwind" {
618 fn CGImageContainsImageSpecificToneMappingMetadata(image: Option<&CGImage>) -> bool;
619 }
620 unsafe { CGImageContainsImageSpecificToneMappingMetadata(image) }
621 }
622
623 #[doc(alias = "CGImageGetUTType")]
624 #[inline]
625 pub unsafe fn ut_type(image: Option<&CGImage>) -> Option<CFRetained<CFString>> {
626 extern "C-unwind" {
627 fn CGImageGetUTType(image: Option<&CGImage>) -> Option<NonNull<CFString>>;
628 }
629 let ret = unsafe { CGImageGetUTType(image) };
630 ret.map(|ret| unsafe { CFRetained::retain(ret) })
631 }
632}
633
634#[cfg(all(feature = "CGColorSpace", feature = "CGDataProvider"))]
635#[deprecated = "renamed to `CGImage::new`"]
636#[inline]
637pub unsafe extern "C-unwind" fn CGImageCreate(
638 width: usize,
639 height: usize,
640 bits_per_component: usize,
641 bits_per_pixel: usize,
642 bytes_per_row: usize,
643 space: Option<&CGColorSpace>,
644 bitmap_info: CGBitmapInfo,
645 provider: Option<&CGDataProvider>,
646 decode: *const CGFloat,
647 should_interpolate: bool,
648 intent: CGColorRenderingIntent,
649) -> Option<CFRetained<CGImage>> {
650 extern "C-unwind" {
651 fn CGImageCreate(
652 width: usize,
653 height: usize,
654 bits_per_component: usize,
655 bits_per_pixel: usize,
656 bytes_per_row: usize,
657 space: Option<&CGColorSpace>,
658 bitmap_info: CGBitmapInfo,
659 provider: Option<&CGDataProvider>,
660 decode: *const CGFloat,
661 should_interpolate: bool,
662 intent: CGColorRenderingIntent,
663 ) -> Option<NonNull<CGImage>>;
664 }
665 let ret = unsafe {
666 CGImageCreate(
667 width,
668 height,
669 bits_per_component,
670 bits_per_pixel,
671 bytes_per_row,
672 space,
673 bitmap_info,
674 provider,
675 decode,
676 should_interpolate,
677 intent,
678 )
679 };
680 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
681}
682
683#[cfg(feature = "CGDataProvider")]
684#[deprecated = "renamed to `CGImage::mask_create`"]
685#[inline]
686pub unsafe extern "C-unwind" fn CGImageMaskCreate(
687 width: usize,
688 height: usize,
689 bits_per_component: usize,
690 bits_per_pixel: usize,
691 bytes_per_row: usize,
692 provider: Option<&CGDataProvider>,
693 decode: *const CGFloat,
694 should_interpolate: bool,
695) -> Option<CFRetained<CGImage>> {
696 extern "C-unwind" {
697 fn CGImageMaskCreate(
698 width: usize,
699 height: usize,
700 bits_per_component: usize,
701 bits_per_pixel: usize,
702 bytes_per_row: usize,
703 provider: Option<&CGDataProvider>,
704 decode: *const CGFloat,
705 should_interpolate: bool,
706 ) -> Option<NonNull<CGImage>>;
707 }
708 let ret = unsafe {
709 CGImageMaskCreate(
710 width,
711 height,
712 bits_per_component,
713 bits_per_pixel,
714 bytes_per_row,
715 provider,
716 decode,
717 should_interpolate,
718 )
719 };
720 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
721}
722
723#[deprecated = "renamed to `CGImage::new_copy`"]
724#[inline]
725pub unsafe extern "C-unwind" fn CGImageCreateCopy(
726 image: Option<&CGImage>,
727) -> Option<CFRetained<CGImage>> {
728 extern "C-unwind" {
729 fn CGImageCreateCopy(image: Option<&CGImage>) -> Option<NonNull<CGImage>>;
730 }
731 let ret = unsafe { CGImageCreateCopy(image) };
732 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
733}
734
735#[cfg(all(feature = "CGColorSpace", feature = "CGDataProvider"))]
736#[deprecated = "renamed to `CGImage::with_jpeg_data_provider`"]
737#[inline]
738pub unsafe extern "C-unwind" fn CGImageCreateWithJPEGDataProvider(
739 source: Option<&CGDataProvider>,
740 decode: *const CGFloat,
741 should_interpolate: bool,
742 intent: CGColorRenderingIntent,
743) -> Option<CFRetained<CGImage>> {
744 extern "C-unwind" {
745 fn CGImageCreateWithJPEGDataProvider(
746 source: Option<&CGDataProvider>,
747 decode: *const CGFloat,
748 should_interpolate: bool,
749 intent: CGColorRenderingIntent,
750 ) -> Option<NonNull<CGImage>>;
751 }
752 let ret =
753 unsafe { CGImageCreateWithJPEGDataProvider(source, decode, should_interpolate, intent) };
754 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
755}
756
757#[cfg(all(feature = "CGColorSpace", feature = "CGDataProvider"))]
758#[deprecated = "renamed to `CGImage::with_png_data_provider`"]
759#[inline]
760pub unsafe extern "C-unwind" fn CGImageCreateWithPNGDataProvider(
761 source: Option<&CGDataProvider>,
762 decode: *const CGFloat,
763 should_interpolate: bool,
764 intent: CGColorRenderingIntent,
765) -> Option<CFRetained<CGImage>> {
766 extern "C-unwind" {
767 fn CGImageCreateWithPNGDataProvider(
768 source: Option<&CGDataProvider>,
769 decode: *const CGFloat,
770 should_interpolate: bool,
771 intent: CGColorRenderingIntent,
772 ) -> Option<NonNull<CGImage>>;
773 }
774 let ret =
775 unsafe { CGImageCreateWithPNGDataProvider(source, decode, should_interpolate, intent) };
776 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
777}
778
779#[deprecated = "renamed to `CGImage::with_image_in_rect`"]
780#[inline]
781pub unsafe extern "C-unwind" fn CGImageCreateWithImageInRect(
782 image: Option<&CGImage>,
783 rect: CGRect,
784) -> Option<CFRetained<CGImage>> {
785 extern "C-unwind" {
786 fn CGImageCreateWithImageInRect(
787 image: Option<&CGImage>,
788 rect: CGRect,
789 ) -> Option<NonNull<CGImage>>;
790 }
791 let ret = unsafe { CGImageCreateWithImageInRect(image, rect) };
792 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
793}
794
795#[deprecated = "renamed to `CGImage::with_mask`"]
796#[inline]
797pub unsafe extern "C-unwind" fn CGImageCreateWithMask(
798 image: Option<&CGImage>,
799 mask: Option<&CGImage>,
800) -> Option<CFRetained<CGImage>> {
801 extern "C-unwind" {
802 fn CGImageCreateWithMask(
803 image: Option<&CGImage>,
804 mask: Option<&CGImage>,
805 ) -> Option<NonNull<CGImage>>;
806 }
807 let ret = unsafe { CGImageCreateWithMask(image, mask) };
808 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
809}
810
811#[deprecated = "renamed to `CGImage::with_masking_colors`"]
812#[inline]
813pub unsafe extern "C-unwind" fn CGImageCreateWithMaskingColors(
814 image: Option<&CGImage>,
815 components: *const CGFloat,
816) -> Option<CFRetained<CGImage>> {
817 extern "C-unwind" {
818 fn CGImageCreateWithMaskingColors(
819 image: Option<&CGImage>,
820 components: *const CGFloat,
821 ) -> Option<NonNull<CGImage>>;
822 }
823 let ret = unsafe { CGImageCreateWithMaskingColors(image, components) };
824 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
825}
826
827#[cfg(feature = "CGColorSpace")]
828#[deprecated = "renamed to `CGImage::new_copy_with_color_space`"]
829#[inline]
830pub unsafe extern "C-unwind" fn CGImageCreateCopyWithColorSpace(
831 image: Option<&CGImage>,
832 space: Option<&CGColorSpace>,
833) -> Option<CFRetained<CGImage>> {
834 extern "C-unwind" {
835 fn CGImageCreateCopyWithColorSpace(
836 image: Option<&CGImage>,
837 space: Option<&CGColorSpace>,
838 ) -> Option<NonNull<CGImage>>;
839 }
840 let ret = unsafe { CGImageCreateCopyWithColorSpace(image, space) };
841 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
842}
843
844#[cfg(all(feature = "CGColorSpace", feature = "CGDataProvider"))]
845#[deprecated = "renamed to `CGImage::with_content_headroom`"]
846#[inline]
847pub unsafe extern "C-unwind" fn CGImageCreateWithContentHeadroom(
848 headroom: c_float,
849 width: usize,
850 height: usize,
851 bits_per_component: usize,
852 bits_per_pixel: usize,
853 bytes_per_row: usize,
854 space: Option<&CGColorSpace>,
855 bitmap_info: CGBitmapInfo,
856 provider: Option<&CGDataProvider>,
857 decode: *const CGFloat,
858 should_interpolate: bool,
859 intent: CGColorRenderingIntent,
860) -> Option<CFRetained<CGImage>> {
861 extern "C-unwind" {
862 fn CGImageCreateWithContentHeadroom(
863 headroom: c_float,
864 width: usize,
865 height: usize,
866 bits_per_component: usize,
867 bits_per_pixel: usize,
868 bytes_per_row: usize,
869 space: Option<&CGColorSpace>,
870 bitmap_info: CGBitmapInfo,
871 provider: Option<&CGDataProvider>,
872 decode: *const CGFloat,
873 should_interpolate: bool,
874 intent: CGColorRenderingIntent,
875 ) -> Option<NonNull<CGImage>>;
876 }
877 let ret = unsafe {
878 CGImageCreateWithContentHeadroom(
879 headroom,
880 width,
881 height,
882 bits_per_component,
883 bits_per_pixel,
884 bytes_per_row,
885 space,
886 bitmap_info,
887 provider,
888 decode,
889 should_interpolate,
890 intent,
891 )
892 };
893 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
894}
895
896#[deprecated = "renamed to `CGImage::new_copy_with_content_headroom`"]
897#[inline]
898pub unsafe extern "C-unwind" fn CGImageCreateCopyWithContentHeadroom(
899 headroom: c_float,
900 image: Option<&CGImage>,
901) -> Option<CFRetained<CGImage>> {
902 extern "C-unwind" {
903 fn CGImageCreateCopyWithContentHeadroom(
904 headroom: c_float,
905 image: Option<&CGImage>,
906 ) -> Option<NonNull<CGImage>>;
907 }
908 let ret = unsafe { CGImageCreateCopyWithContentHeadroom(headroom, image) };
909 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
910}
911
912extern "C-unwind" {
913 #[deprecated = "renamed to `CGImage::content_headroom`"]
914 pub fn CGImageGetContentHeadroom(image: Option<&CGImage>) -> c_float;
915}
916
917extern "C-unwind" {
918 #[deprecated = "renamed to `CGImage::is_mask`"]
919 pub fn CGImageIsMask(image: Option<&CGImage>) -> bool;
920}
921
922extern "C-unwind" {
923 #[deprecated = "renamed to `CGImage::width`"]
924 pub fn CGImageGetWidth(image: Option<&CGImage>) -> usize;
925}
926
927extern "C-unwind" {
928 #[deprecated = "renamed to `CGImage::height`"]
929 pub fn CGImageGetHeight(image: Option<&CGImage>) -> usize;
930}
931
932extern "C-unwind" {
933 #[deprecated = "renamed to `CGImage::bits_per_component`"]
934 pub fn CGImageGetBitsPerComponent(image: Option<&CGImage>) -> usize;
935}
936
937extern "C-unwind" {
938 #[deprecated = "renamed to `CGImage::bits_per_pixel`"]
939 pub fn CGImageGetBitsPerPixel(image: Option<&CGImage>) -> usize;
940}
941
942extern "C-unwind" {
943 #[deprecated = "renamed to `CGImage::bytes_per_row`"]
944 pub fn CGImageGetBytesPerRow(image: Option<&CGImage>) -> usize;
945}
946
947#[cfg(feature = "CGColorSpace")]
948#[deprecated = "renamed to `CGImage::color_space`"]
949#[inline]
950pub unsafe extern "C-unwind" fn CGImageGetColorSpace(
951 image: Option<&CGImage>,
952) -> Option<CFRetained<CGColorSpace>> {
953 extern "C-unwind" {
954 fn CGImageGetColorSpace(image: Option<&CGImage>) -> Option<NonNull<CGColorSpace>>;
955 }
956 let ret = unsafe { CGImageGetColorSpace(image) };
957 ret.map(|ret| unsafe { CFRetained::retain(ret) })
958}
959
960extern "C-unwind" {
961 #[deprecated = "renamed to `CGImage::alpha_info`"]
962 pub fn CGImageGetAlphaInfo(image: Option<&CGImage>) -> CGImageAlphaInfo;
963}
964
965#[cfg(feature = "CGDataProvider")]
966#[deprecated = "renamed to `CGImage::data_provider`"]
967#[inline]
968pub unsafe extern "C-unwind" fn CGImageGetDataProvider(
969 image: Option<&CGImage>,
970) -> Option<CFRetained<CGDataProvider>> {
971 extern "C-unwind" {
972 fn CGImageGetDataProvider(image: Option<&CGImage>) -> Option<NonNull<CGDataProvider>>;
973 }
974 let ret = unsafe { CGImageGetDataProvider(image) };
975 ret.map(|ret| unsafe { CFRetained::retain(ret) })
976}
977
978extern "C-unwind" {
979 #[deprecated = "renamed to `CGImage::decode`"]
980 pub fn CGImageGetDecode(image: Option<&CGImage>) -> *const CGFloat;
981}
982
983extern "C-unwind" {
984 #[deprecated = "renamed to `CGImage::should_interpolate`"]
985 pub fn CGImageGetShouldInterpolate(image: Option<&CGImage>) -> bool;
986}
987
988extern "C-unwind" {
989 #[cfg(feature = "CGColorSpace")]
990 #[deprecated = "renamed to `CGImage::rendering_intent`"]
991 pub fn CGImageGetRenderingIntent(image: Option<&CGImage>) -> CGColorRenderingIntent;
992}
993
994extern "C-unwind" {
995 #[deprecated = "renamed to `CGImage::bitmap_info`"]
996 pub fn CGImageGetBitmapInfo(image: Option<&CGImage>) -> CGBitmapInfo;
997}
998
999extern "C-unwind" {
1000 #[deprecated = "renamed to `CGImage::byte_order_info`"]
1001 pub fn CGImageGetByteOrderInfo(image: Option<&CGImage>) -> CGImageByteOrderInfo;
1002}
1003
1004extern "C-unwind" {
1005 #[deprecated = "renamed to `CGImage::pixel_format_info`"]
1006 pub fn CGImageGetPixelFormatInfo(image: Option<&CGImage>) -> CGImagePixelFormatInfo;
1007}
1008
1009extern "C-unwind" {
1010 #[deprecated = "renamed to `CGImage::should_tone_map`"]
1011 pub fn CGImageShouldToneMap(image: Option<&CGImage>) -> bool;
1012}
1013
1014extern "C-unwind" {
1015 #[deprecated = "renamed to `CGImage::contains_image_specific_tone_mapping_metadata`"]
1016 pub fn CGImageContainsImageSpecificToneMappingMetadata(image: Option<&CGImage>) -> bool;
1017}
1018
1019#[deprecated = "renamed to `CGImage::ut_type`"]
1020#[inline]
1021pub unsafe extern "C-unwind" fn CGImageGetUTType(
1022 image: Option<&CGImage>,
1023) -> Option<CFRetained<CFString>> {
1024 extern "C-unwind" {
1025 fn CGImageGetUTType(image: Option<&CGImage>) -> Option<NonNull<CFString>>;
1026 }
1027 let ret = unsafe { CGImageGetUTType(image) };
1028 ret.map(|ret| unsafe { CFRetained::retain(ret) })
1029}