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    ///
27    /// # Safety
28    ///
29    /// - `allocator` might not allow `None`.
30    /// - `url` might not allow `None`.
31    /// - `options` generics must be of the correct type.
32    /// - `options` might not allow `None`.
33    #[doc(alias = "QLThumbnailImageCreate")]
34    #[cfg(feature = "objc2-core-graphics")]
35    #[deprecated = "Use QuickLookThumbnailing to generate thumbnails for files."]
36    #[inline]
37    pub unsafe fn image_create(
38        allocator: Option<&CFAllocator>,
39        url: Option<&CFURL>,
40        max_thumbnail_size: CGSize,
41        options: Option<&CFDictionary>,
42    ) -> Option<CFRetained<CGImage>> {
43        extern "C-unwind" {
44            fn QLThumbnailImageCreate(
45                allocator: Option<&CFAllocator>,
46                url: Option<&CFURL>,
47                max_thumbnail_size: CGSize,
48                options: Option<&CFDictionary>,
49            ) -> Option<NonNull<CGImage>>;
50        }
51        let ret = unsafe { QLThumbnailImageCreate(allocator, url, max_thumbnail_size, options) };
52        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
53    }
54}
55
56extern "C" {
57    /// If kCFBooleanTrue, QL will produce an icon (ie a thumbnail and all the icon decor, like shadows, curled corner, etc.).
58    ///
59    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklook/kqlthumbnailoptioniconmodekey?language=objc)
60    pub static kQLThumbnailOptionIconModeKey: Option<&'static CFString>;
61}
62
63extern "C" {
64    /// This is the user scale factor (as a CFNumber). If absent, default value is 1.0
65    ///
66    /// See also [Apple's documentation](https://developer.apple.com/documentation/quicklook/kqlthumbnailoptionscalefactorkey?language=objc)
67    pub static kQLThumbnailOptionScaleFactorKey: Option<&'static CFString>;
68}
69
70#[cfg(feature = "objc2-core-graphics")]
71#[deprecated = "renamed to `QLThumbnail::image_create`"]
72#[inline]
73pub unsafe extern "C-unwind" fn QLThumbnailImageCreate(
74    allocator: Option<&CFAllocator>,
75    url: Option<&CFURL>,
76    max_thumbnail_size: CGSize,
77    options: Option<&CFDictionary>,
78) -> Option<CFRetained<CGImage>> {
79    extern "C-unwind" {
80        fn QLThumbnailImageCreate(
81            allocator: Option<&CFAllocator>,
82            url: Option<&CFURL>,
83            max_thumbnail_size: CGSize,
84            options: Option<&CFDictionary>,
85        ) -> Option<NonNull<CGImage>>;
86    }
87    let ret = unsafe { QLThumbnailImageCreate(allocator, url, max_thumbnail_size, options) };
88    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
89}