objc2_quick_look/generated/
QLThumbnailImage.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2_core_foundation::*;
5#[cfg(feature = "objc2-core-graphics")]
6use objc2_core_graphics::*;
7
8use crate::*;
9
10#[cfg(feature = "QLThumbnail")]
11impl QLThumbnail {
12    /// Creates a thumbnail for the designated file. Returns NULL if Quick Look does not support this file type.
13    ///
14    /// Parameter `allocator`: The allocator to use to create the image.
15    ///
16    /// Parameter `url`: The URL to the file.
17    ///
18    /// Parameter `maxThumbnailSize`: The maximum desired size.
19    ///
20    /// Parameter `options`: See options below.
21    ///
22    /// Returns: The thumbnail image. NULL if not available.
23    ///
24    /// QLThumbnailImageCreate() does not replace IconServices.
25    /// Also QLThumbnailImageCreate() will block until the thumbnail is generated so you should consider calling it in a thread.
26    #[doc(alias = "QLThumbnailImageCreate")]
27    #[cfg(feature = "objc2-core-graphics")]
28    #[deprecated = "Use QuickLookThumbnailing to generate thumbnails for files."]
29    #[inline]
30    pub unsafe fn image_create(
31        allocator: Option<&CFAllocator>,
32        url: Option<&CFURL>,
33        max_thumbnail_size: CGSize,
34        options: Option<&CFDictionary>,
35    ) -> Option<CFRetained<CGImage>> {
36        extern "C-unwind" {
37            fn QLThumbnailImageCreate(
38                allocator: Option<&CFAllocator>,
39                url: Option<&CFURL>,
40                max_thumbnail_size: CGSize,
41                options: Option<&CFDictionary>,
42            ) -> Option<NonNull<CGImage>>;
43        }
44        let ret = unsafe { QLThumbnailImageCreate(allocator, url, max_thumbnail_size, options) };
45        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
46    }
47}
48
49extern "C" {
50    /// If kCFBooleanTrue, QL will produce an icon (ie a thumbnail and all the icon decor, like shadows, curled corner, etc.).
51    ///
52    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklook/kqlthumbnailoptioniconmodekey?language=objc)
53    pub static kQLThumbnailOptionIconModeKey: Option<&'static CFString>;
54}
55
56extern "C" {
57    /// This is the user scale factor (as a CFNumber). If absent, default value is 1.0
58    ///
59    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklook/kqlthumbnailoptionscalefactorkey?language=objc)
60    pub static kQLThumbnailOptionScaleFactorKey: Option<&'static CFString>;
61}
62
63#[cfg(feature = "objc2-core-graphics")]
64#[deprecated = "renamed to `QLThumbnail::image_create`"]
65#[inline]
66pub unsafe extern "C-unwind" fn QLThumbnailImageCreate(
67    allocator: Option<&CFAllocator>,
68    url: Option<&CFURL>,
69    max_thumbnail_size: CGSize,
70    options: Option<&CFDictionary>,
71) -> Option<CFRetained<CGImage>> {
72    extern "C-unwind" {
73        fn QLThumbnailImageCreate(
74            allocator: Option<&CFAllocator>,
75            url: Option<&CFURL>,
76            max_thumbnail_size: CGSize,
77            options: Option<&CFDictionary>,
78        ) -> Option<NonNull<CGImage>>;
79    }
80    let ret = unsafe { QLThumbnailImageCreate(allocator, url, max_thumbnail_size, options) };
81    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
82}